示例#1
0
文件: main.py 项目: IDCH/lha
def get_or_create_person(authorname, app):
    """ Retrieves the person object that represents the author of this document
        or creates a new person if no person with this name exists.

        NOTE that this does not yet enable disambiguation of multiple people 
        with the same name.
    """
    (last, first) = Person.parse(authorname)
    people = Person.get(last, first)
    if people:
        person = people[0]
        app.log.debug("Retrieved author (%s)..." % (person))
    else:
        app.log.info("Creating author (%s)..." % (authorname))
        person = Person.create(authorname)

    return person
示例#2
0
文件: importer.py 项目: IDCH/lha
 def _create_author(self, document, authorname, role="Author"):
     if not authorname:
         return None
     
     (last, first) = Person.parse(authorname)
     people = Person.get(last, first)
     if people:
         person = people[0]
     else:
         print("    Creating author (%s)..." % (authorname))
         person = Person.create(authorname)
     
     if role == "tr":
         role = "Translator"
     elif role == "ed":
         role = "Editor"
     elif not role:
         role = "Author"
     
     author = document.add_author(person, role)
     return author
示例#3
0
文件: views.py 项目: IDCH/lha
 def __init__(self, request, auth_id):
     self.auth_id = auth_id
     self.request = request
     self.person = Person.get_by_id(auth_id)