Skip to content

Commit cdeb47f

Browse files
committed
Pathec draft.py for including full name, middle initial and name suffix in authors info. See ietf-tools#626
- Legacy-Id: 2901
1 parent 6f6d720 commit cdeb47f

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

ietf/utils/draft.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@ def extract_authors(self):
464464
author = authors[i]
465465
if author == None:
466466
continue
467+
suffix_match = re.search(" %(suffix)s$" % aux, author)
468+
if suffix_match:
469+
suffix = suffix_match.group(1)
470+
author = author[:-len(suffix)].strip()
471+
else:
472+
suffix = None
467473
if "," in author:
468474
last, first = author.split(",",1)
469475
author = "%s %s" % (first.strip(), last.strip())
@@ -548,11 +554,20 @@ def extract_authors(self):
548554
fullname = author_match
549555
fullname = re.sub(" +", " ", fullname)
550556
if fullname.endswith(surname):
551-
authors[i] = ( fullname.replace(surname, "").strip(), surname )
557+
given_names = fullname.replace(surname, "").strip()
558+
else:
559+
given_names, surname = fullname.rsplit(None, 1)
560+
if " " in given_names:
561+
first, middle = given_names.split(None, 1)
552562
else:
553-
authors[i] = tuple(fullname.rsplit(None, 1))
554-
if not " ".join(authors[i]) == fullname:
563+
first = given_names
564+
middle = None
565+
names = (first, middle, surname, suffix)
566+
if suffix:
567+
fullname = fullname+" "+suffix
568+
if not " ".join([ n for n in names if n ]) == fullname:
555569
_err("Author tuple doesn't match text in draft: %s, %s" % (authors[i], fullname))
570+
authors[i] = (fullname, first, middle, surname, suffix)
556571
#_debug( "Author: %s: %s" % (author_match, authors[author_match]))
557572
break
558573
except AssertionError, e:
@@ -644,7 +659,7 @@ def extract_authors(self):
644659
authors = [ a for a in authors if a != None ]
645660
_debug(" * Final author tuples: %s" % (authors,))
646661
self._author_info = authors
647-
self._authors = [ "%s %s <%s>"%(first,last,email) if email else "%s %s"%(first, last) for first,last,email in authors ]
662+
self._authors = [ "%s <%s>"%(full,email) if email else full for full,first,middle,last,suffix,email in authors ]
648663
self._authors.sort()
649664
_debug(" * Final author list: " + ", ".join(self._authors))
650665
_debug("-"*72)
@@ -759,7 +774,7 @@ def _printmeta(timestamp, fn):
759774
fields["doctitle"] = draft.get_title()
760775
fields["docpages"] = str(draft.get_pagecount())
761776
fields["docauthors"] = ", ".join(draft.get_authors())
762-
fields["docauthinfo"] = str(draft.get_author_info())
777+
# fields["docauthinfo"] = str(draft.get_author_info())
763778
normrefs, rfcrefs, refs = draft.get_refs()
764779
fields["docrfcrefs"] = ", ".join(rfcrefs)
765780
fields["doccreationdate"] = str(draft.get_creation_date())

0 commit comments

Comments
 (0)