How to use the biblib.services.creator_service.formatted_name_to_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 / csv_crosswalk.py View on Github external
#logging.debug("csv_dict_reader_to_metasjon type(csv_row): {}".format(type(csv_row)))
        #print csv_row
        document["title"] = csv_row["title"]
        classifications_sitpol = [x.strip() for x in csv_row["classifications_sitpol"].split(";") if x.strip()]
        if classifications_sitpol:
            document["classifications_sitpol"] = classifications_sitpol
        classifications_ddc = [x.strip() for x in csv_row["classifications_ddc"].split(";") if x.strip()]
        if classifications_ddc:
            document["classifications_ddc"] = classifications_ddc
        formatted_names = [x.strip() for x in csv_row["creators@role=pbl"].split(";") if x.strip()]
        if formatted_names:
            #logging.debug("formatted_names: {}".format(formatted_names))
            creators = []
            for formatted_name in formatted_names:
                if formatted_name:
                    creator = creator_service.formatted_name_to_creator(formatted_name, None, "pbl")
                    if creator:
                        creators.append(creator)
            if creators:
                document["creators"] = creators
        document["date_last_accessed"] = datetime.now().isoformat()
        document["descriptions"] = [{"language":"fr", "value":csv_row["descriptions@lang=fr"]}]
        keywords_fr = [x.strip() for x in csv_row["keywords@lang=fr"].split(";") if x.strip()]
        keywords_en = [x.strip() for x in csv_row["keywords@lang=en"].split(";") if x.strip()]
        keywords = {}
        if keywords_fr:
            keywords["fr"] = keywords_fr
        if keywords_en:
            keywords["en"] = keywords_en
        if keywords:
            document["keywords"] = keywords
        document["languages"] = [x.strip() for x in csv_row["languages"].split(";") if x.strip()]
github medialab / reference_manager / biblib / crosswalks / researcherml_crosswalk.py View on Github external
def get_rml_call(rml):
    """ call -> call """
    result = {}
    rml_call = rml.find(xmletree.prefixtag("rml", "call"))
    if rml_call is not None:
        call = Call()

        # funding -> funding
        rml_funding = rml_call.find(xmletree.prefixtag("rml", "funding"))
        if rml_funding is not None:
            # name -> agent.name
            name = get_rml_element_text(rml_funding, "name")
            funding = creator_service.formatted_name_to_creator(name, constants.REC_CLASS_ORGUNIT, None)
            if funding is None:
                funding = Creator()
                funding["agent"] = Orgunit()

            # identifier -> agent.rec_id & agent.identifiers
            funding["agent"].update(get_rml_identifiers(rml_funding))

            # programme -> programme
            funding.update(get_rml_element_text_and_set_key(rml_funding, "programme", "programme"))

            # scheme -> scheme
            funding.update(get_rml_element_text_and_set_key(rml_funding, "scheme", "scheme"))

            # contribution -> contribution
            funding.update(get_rml_money_and_set_key(rml_funding, "contribution", "contribution"))
github medialab / reference_manager / biblib / crosswalks / researcherml_crosswalk.py View on Github external
def get_rml_relationships(rml):
    """ relationship -> relationships """
    result = {}
    rml_relationships = rml.findall(xmletree.prefixtag("rml", "relationship"))
    if rml_relationships is not None:
        relationships = []
        for rml_relationship in rml_relationships:
            if rml_relationship is not None:
                # name -> agent.name
                name = get_rml_element_text(rml_relationship, "name")
                relationship = creator_service.formatted_name_to_creator(name, constants.REC_CLASS_PERSON, None)
                if relationship is None:
                    relationship = {}
                    relationship["agent"] = Person()

                # identifier -> agent.rec_id & agent.identifiers
                relationship["agent"].update(get_rml_identifiers(rml_relationship))

                # relationType -> relation_type
                relationship.update(get_rml_element_text_and_set_key(rml_relationship, "relationType", "relation_type"))

                # descriptions -> descriptions
                relationship.update(get_rml_textlangs_and_set_key(rml_relationship, "description", "descriptions"))

                if relationship is not None:
                    relationships.append(relationship)
        if relationships:
github medialab / reference_manager / biblib / crosswalks / ris_crosswalk.py View on Github external
# Title Primary -> title
                    document["title"] = value
                elif key in ["JF", "JO"] or (key == "BT" and ris_type not in [RIS_TYPE_BOOK, RIS_TYPE_UNPB]):
                    # Title Secondary -> is_part_of["title"]
                    document.add_is_part_of_title(value)
                elif key in ["JA", "J1", "J2", "T2"]:
                    # Title Secondary -> is_part_of["title_abbreviateds"][O]["title"]
                    document.add_is_part_of_title_abbreviated(value)
                elif key == "T3":
                    # Title Series
                    document.add_series_title(value)
                elif key in ["A1", "AU"]:
                    document.add_creator(creator_service.formatted_name_to_creator(value, None, "aut"))
                elif key in ["A2", "ED"]:
                    if is_part_of_rec_type:
                        document.add_is_part_of_creator(creator_service.formatted_name_to_creator(value, None, "edt"))
                    else:
                        document.add_creator(creator_service.formatted_name_to_creator(value, None, "edt"))
                elif key == "A3":
                    document.add_series_creator(creator_service.formatted_name_to_creator(value, None, "aut"))
                elif key == "A4":
                    document.add_creator(creator_service.formatted_name_to_creator(value, None, "ctb"))
                elif key in ["PY", "Y1", "DA"]:
                    index_slash = value.find("/")
                    if index_slash != -1:
                        # YYYY/MM/DD/other info (like season)
                        # todo
                        document["date_issued"] = value.strip("/")
                    else:
                        document["date_issued"] = value
                elif key == "SP":
                    document["part_page_begin"] = value