How to use the biblib.metajson.Creator function in biblib

To help you get started, we’ve selected a few biblib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github medialab / reference_manager / biblib / crosswalks / researcherml_crosswalk.py View on Github external
# description -> descriptions[i]
                teaching.update(get_rml_textlangs_and_set_key(rml_teaching, "description", "descriptions"))

                # level -> level
                teaching.update(get_rml_element_text_and_set_key(rml_teaching, "level", "level"))

                # title -> title
                teaching.update(get_rml_element_text_and_set_key(rml_teaching, "title", "title"))

                # creators
                # name -> creators[0].agent.name
                name = get_rml_element_text(rml_teaching, "name")
                creator = creator_service.formatted_name_to_creator(name, constants.REC_CLASS_ORGUNIT, "dgg")
                if creator is None:
                    creator = Creator()
                    creator["agent"] = Orgunit()
                    creator["roles"] = "dgg"

                # identifiers -> creators[0].agent.rec_id or creators[0].agent.identifiers
                creator["agent"].update(get_rml_identifiers(rml_teaching))

                if "name" in creator["agent"] or "rec_id" in creator["agent"] or "identifiers" in creator["agent"]:
                    teaching["creators"] = [creator]

                if teaching is not None:
                    teachings.append(teaching)
        if teachings:
            result["teachings"] = teachings
    return result
github medialab / reference_manager / biblib / crosswalks / mods_crosswalk.py View on Github external
def convert_mods_name_dai_dict_to_creator(mods_name, dai_dict):
    """ name, extension/daiList -> creator """
    if mods_name is not None:
        creator = Creator()
        # extract mods properties
        # type
        mods_name_type = mods_name.get("type")
        # ID
        mods_name_id = mods_name.get("ID")
        # namePart
        mods_name_parts = mods_name.findall(xmletree.prefixtag("mods", "namePart"))
        # affiliation
        mods_name_affiliations = mods_name.findall(xmletree.prefixtag("mods", "affiliation"))
        # role
        mods_name_role = mods_name.find(xmletree.prefixtag("mods", "role"))
        mods_name_roleterm = None
        if mods_name_role is not None:
            mods_name_roleterm = mods_name_role.find(xmletree.prefixtag("mods", "roleTerm"))
        # description
        mods_name_descriptions = mods_name.findall(xmletree.prefixtag("mods", "description"))
github medialab / reference_manager / biblib / crosswalks / unimarc_crosswalk.py View on Github external
def extract_unimarc_creator(field):
    if field:
        creator = Creator()
        # $4 -> role
        if field['4'] and field['4'] in creator_service.role_unimarc_to_role_code:
            creator["roles"] = [creator_service.role_unimarc_to_role_code[field['4']]]
        elif field.tag in ["700", "701", "710", "711", "720", "721", "740", "741"]:
            creator["roles"] = ["aut"]
        else:
            creator["roles"] = ["ctb"]

        # 600, 700, 701, 702 -> Person
        if field.tag in ["600", "700", "701", "702"]:
            # Person
            person = Person()
            if field.subfields:
                if field.get_subfields('a'):
                    # name_family
                    person["name_family"] = "".join(field.get_subfields('a'))
github medialab / reference_manager / biblib / crosswalks / summonjson_crosswalk.py View on Github external
def convert_creators(sum_doc, sum_authors_key, sum_affiliations_key, creator_type, role):
    creators = []
    if sum_authors_key in sum_doc:
        sum_authors = sum_doc[sum_authors_key]
        if sum_authors:
            affiliations_dict = {}
            if sum_affiliations_key in sum_doc:
                sum_affiliations = sum_doc[sum_affiliations_key]
                if sum_affiliations:
                    for index, affiliation in enumerate(sum_affiliations):
                        affiliations_dict[index + 1] = affiliation

            for author in sum_authors:
                creator = Creator()
                if "surname" in author and "givenname" in author:
                    person = Person()
                    person.set_key_if_not_none("name_family", author["surname"])
                    person.set_key_if_not_none("name_given", author["givenname"])
                    creator["agent"] = person
                    if role:
                        creator["roles"] = [role]
                else:
                    formatted_name = ""
                    if "fullname" in author:
                        formatted_name = author["fullname"]
                    elif "name" in author:
                        formatted_name = author["name"]

                    creator = creator_service.formatted_name_to_creator(formatted_name, creator_type, role)
                if "sequence" in author and author["sequence"] in affiliations_dict:
github medialab / reference_manager / biblib / metajson.py View on Github external
def __init__(self, *args, **kwargs):
        Common.__init__(self, *args, **kwargs)
        if "rec_class" not in self:
            self["rec_class"] = constants.REC_CLASS_DOCUMENT
        if "creators" in self:
            self["creators"] = [Creator(x) for x in self["creators"]]
        if "absorbs" in self:
            self["absorbs"] = [Document(x) for x in self["absorbs"]]
        if "aggregates" in self:
            self["aggregates"] = [Document(x) for x in self["aggregates"]]
        if "becomes" in self:
            self["becomes"] = [Document(x) for x in self["becomes"]]
        if "conforms_tos" in self:
            self["conforms_tos"] = [Document(x) for x in self["conforms_tos"]]
        if "continues" in self:
            self["continues"] = [Document(x) for x in self["continues"]]
        if "describes" in self:
            self["describes"] = [Document(x) for x in self["describes"]]
        if "has_formats" in self:
            self["has_formats"] = [Document(x) for x in self["has_formats"]]
        if "has_offprints" in self:
            self["has_offprints"] = [Document(x) for x in self["has_offprints"]]