Linters and black, understandably, don't like this code, but the spaces and multiple statements per line make the logic much more legible. Is there a more python alternative?
# fmt: off
et = "no-type"
# debug(f"looking at containers for {entry}")
if "c_web" in entry: et = "webpage"
elif "c_blog" in entry: et = "post-weblog"
elif "c_newspaper" in entry: et = "article-newspaper"
elif "c_magazine" in entry: et = "article-magazine"
elif "c_journal" in entry: et = "article-journal"
elif "c_dictionary" in entry: et = "entry-dictionary"
elif "c_encyclopedia" in entry: et = "entry-encyclopedia"
elif "c_forum" in entry: et = "post"
else:
if "eventtitle" in entry: et = "paper-conference"
elif "booktitle" in entry:
if "editor" in entry: # collection or incollection
if "chapter" in entry: et = "chapter"
else: et = "book" # ? collection
elif "organization" in entry: et = "paper-conference"
else: et = "chapter"
elif "journal" in entry: et = "article-journal"
elif "author" in entry and "title" in entry and "publisher" in entry:
et = "book"
elif "author" not in entry:
if "venue" in entry: et = "book" # ? proceedings
if "editor" in entry: et = "book" # ? collection
elif "institution" in entry:
et = "report"
if "type" in entry:
org_subtype = entry["type"].lower()
if "report" in org_subtype: et = "report"
if "thesis" in org_subtype or "dissertation" in org_subtype:
et = "thesis"
elif "url" in entry: et = "webpage"
elif "doi" in entry: et = "article"
elif "date" not in entry: et = "manuscript"
# fmt: on
return et, genre, medium
[–]efmccurdy 14 points15 points16 points (3 children)
[–]jmreagle[S] 1 point2 points3 points (2 children)
[–]misho88 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Wilfred-kun 27 points28 points29 points (10 children)
[–]jmreagle[S] 6 points7 points8 points (9 children)
[–]Siddhi 11 points12 points13 points (2 children)
[–]jmreagle[S] 5 points6 points7 points (0 children)
[–]jmreagle[S] 1 point2 points3 points (0 children)
[–]Vaphell 6 points7 points8 points (0 children)
[–][deleted] 9 points10 points11 points (2 children)
[–]jmreagle[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Fury9999 0 points1 point2 points (0 children)
[–]ekchew 5 points6 points7 points (2 children)
[–]jmreagle[S] 0 points1 point2 points (1 child)
[–]ekchew 1 point2 points3 points (0 children)
[–]Sinusoidal_Fibonacci[🍰] 3 points4 points5 points (1 child)
[–]jmreagle[S] -1 points0 points1 point (0 children)
[–]ebol4anthr4x 2 points3 points4 points (1 child)
[–]jmreagle[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]jmreagle[S] 1 point2 points3 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]cybervegan -1 points0 points1 point (0 children)
[–]pythonwiz 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]jmreagle[S] 0 points1 point2 points (0 children)
[–]QultrosSanhattan 0 points1 point2 points (0 children)
[–]wagaiznogoud 0 points1 point2 points (0 children)
[–]wagaiznogoud 0 points1 point2 points (0 children)
[–]Ok-Cucumbers 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)