Skip to content

Commit

Permalink
Parse authors that aren't a dictionary of {given: family: }
Browse files Browse the repository at this point in the history
Instead split by spaces (fn ln) or comma (ln fn)
  • Loading branch information
mpharrigan committed Aug 7, 2017
1 parent a6d93b0 commit c9470d4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion gitbib/gitbib.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,22 @@ def _internal_rep_arxiv(my_meta, their_meta, *, ulog):


def _internal_rep_none(my_meta, their_meta, *, ulog):
if 'author' in my_meta:
if isinstance(my_meta['author'], str):
ulog.warn("{}'s `author` field should be a list")
else:
new_auths = []
for a in my_meta['author']:
if isinstance(a, dict):
new_auths += [a]
elif isinstance(a, str):
if ',' in a:
splits = [s.strip() for s in a.split(',')]
new_auths += [{'family': splits[0], 'given': splits[1]}]
else:
splits = a.split()
new_auths += [{'family': splits[-1], 'given': ' '.join(splits[:-1])}]
my_meta['author'] = new_auths
return my_meta


Expand Down Expand Up @@ -324,6 +340,7 @@ def pretty_author_list(authors):
def bibtex_author_list(authors):
return " and ".join(latex_escape(lnfn_name_from_dict(author)) for author in authors)


def bibtex_capitalize(title):
out_words = []

Expand All @@ -339,7 +356,6 @@ def bibtex_capitalize(title):
return "".join(out_words)



def to_isodate(date):
return date.isoformat()

Expand Down

0 comments on commit c9470d4

Please sign in to comment.