How to use the biblib.services.creator_service 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
# dateEnd -> date_end
                teaching.update(get_rml_element_text_and_set_key(rml_teaching, "dateEnd", "date_end"))

                # 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 / unimarc_crosswalk.py View on Github external
related["rec_id"] = subfield[1].strip()
                    elif subfield[0] == "3":
                        related["rec_id"] = subfield[1].strip()
                    elif subfield[0] in ["a", "f", "g"]:
                        if not has_t and subfield[0] == "a" and "title" not in related:
                            related["title"] = subfield[1].strip()
                        else :
                            role = "aut"
                            formatted_name = subfield[1].strip().replace(",...","")
                            # toto : insert this to formatted_name_to_creator
                            if formatted_name.startswith("par "):
                                formatted_name = formatted_name[4:]
                            elif formatted_name.startswith("publ. sous la dir. de "):
                                formatted_name = formatted_name[22:]
                                role = "pbd"
                            creator = creator_service.formatted_name_to_creator(formatted_name, None, role)
                            if creator:
                                creators.append(creator)
                    elif subfield[0] == "b":
                        related["rec_type_description"] = subfield[1].strip()
                    elif subfield[0] == "c":
                        publication_places.append(subfield[1].strip())
                    elif subfield[0] == "d":
                        related["date_issued"] = subfield[1].strip()
                    elif subfield[0] == "e":
                        related["edition"] = subfield[1].strip()
                    elif subfield[0] in ["h", "v"]:
                        related["part_number"] = subfield[1].strip()
                    elif subfield[0] == "i":
                        related["part_name"] = subfield[1].strip()
                    elif subfield[0] == "l":
                        title_alternatives.append(subfield[1].strip())
github medialab / reference_manager / biblib / crosswalks / summonjson_crosswalk.py View on Github external
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:
                    creator["affiliation"] = affiliations_dict[author["sequence"]]

                # todo : location dans le cas des DissertationSchool_xml
                if creator:
                    creators.append(creator)

    return creators
github medialab / reference_manager / biblib / crosswalks / bibtex_crosswalk.py View on Github external
def extract_creators(entry, key, role):
    #logging.debug("extract_creators")
    if key in entry.persons:
        #logging.debug("key: {}".format(key))
        creators = []
        authors = entry.persons[key]
        for author in authors:
            formatted_name = unicode(author).encode('utf-8')
            formatted_name = replace_special_characters(formatted_name)
            creator = creator_service.formatted_name_to_creator(formatted_name, constants.REC_CLASS_PERSON, role)
            creators.append(creator)
            return creators
    else:
        return None
github medialab / reference_manager / biblib / crosswalks / endnotexml_crosswalk.py View on Github external
is_part_of.set_key_if_not_none("publishers", publishers)
            is_part_of.set_key_if_not_none("publication_places", publication_places)
            if isbn_or_issn:
                is_part_of["identifiers"] = [metajson_service.create_identifier(isbn_or_issn_type, isbn_or_issn)]

        if "title" in is_part_of and is_part_of["title"]:
            document.add_items_to_key([is_part_of], "is_part_ofs")

    else:
        if isbn_or_issn:
            document["identifiers"] = [metajson_service.create_identifier(isbn_or_issn_type, isbn_or_issn)]
        if publishers:
            if endnote_type == TYPE_THESIS:
                document.add_creators([creator_service.formatted_name_to_creator(publishers[0], "orgunit", "dgg")])
            elif endnote_type == TYPE_FILM_OR_BROADCAST:
                document.add_creators([creator_service.formatted_name_to_creator(publishers[0], "orgunit", "dst")])
            else:
                document.set_key_if_not_none("publishers", publishers)
        document.set_key_if_not_none("publication_places", publication_places)

    # seriess[]
    if endnote_type in [TYPE_BOOK, TYPE_BOOK_SECTION]:
        series = Document()
        series["rec_type"] = constants.DOC_TYPE_SERIES
        if endnote_type == TYPE_BOOK and title_secondary:
            series.set_key_if_not_none("title", title_secondary)
            series.add_creators(secondary_creators)
            series.set_key_if_not_none("part_volume", part_number)
        if endnote_type == TYPE_BOOK_SECTION and title_tertiary:
            series.set_key_if_not_none("title", title_tertiary)
            series.add_creators(tertiary_creators)
            series.set_key_if_not_none("part_volume", part_number)
github medialab / reference_manager / biblib / services / resource_service.py View on Github external
def format_filename(matajson, file_extension):
    date_issued = None
    first_contrib = None
    title = None
    if "date_issued" in matajson and matajson["date_issued"]:
        # todo get year
        date_issued = matajson["date_issued"]
    else:
        date_issued = ""
    if "creators" in matajson and matajson["creators"]:
        first_contrib = creator_service.formatted_name(matajson["creators"][0])
    else:
        first_contrib = ""

    if "title" in matajson:
        title = matajson["title"]
    else:
        title = ""
    result = []
    for i in date_issued, first_contrib, title:
        if i:
            result.append(i)
    return ".".join("-".join(result), file_extension)
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'))
                if field.get_subfields('b'):
                    # name_given
                    person["name_given"] = "".join(field.get_subfields('b'))
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'))
                if field.get_subfields('b'):
                    # name_given
github medialab / reference_manager / biblib / crosswalks / researcherml_crosswalk.py View on Github external
def get_rml_participants(rml):
    """ participant -> creators """
    result = {}
    rml_participants = rml.findall(xmletree.prefixtag("rml", "participant"))
    if rml_participants is not None:
        creators = []
        for rml_participant in rml_participants:
            if rml_participant is not None:
                creator_name = get_rml_element_text(rml_participant, "name")
                if creator_name:
                    creator_rec_class = xmletree.get_element_attribute(rml_participant, "entityType")
                    if creator_rec_class:
                        creator_rec_class = creator_rec_class.title()
                    creator = creator_service.formatted_name_to_creator(creator_name, creator_rec_class, None)
                    if creator:
                        creators.append(creator)
        if creators:
            result["creators"] = creators
    return result
github medialab / reference_manager / biblib / crosswalks / mods_crosswalk.py View on Github external
def convert_mods_name_roleterm(mods_roleterm):
    """ role/roleTerm -> role """
    if mods_roleterm is not None:
        authority = mods_roleterm.get("authority")
        term_type = mods_roleterm.get("type")
        value = mods_roleterm.text.strip()
        # logging.debug("{} {} {}".format(authority, term_type, value))
        if not value:
            # default creator role
            return ["cre"]
        else:
            if authority == "marcrelator":
                if term_type == "code":
                    return [value]
                elif value in creator_service.role_text_to_role_code:
                    return [creator_service.role_text_to_role_code[value]]
                else:
                    return ["cre"]
            elif authority == "unimarc" and value in creator_service.role_unimarc_to_role_code:
                return [creator_service.role_unimarc_to_role_code[value]]
            else:
                return ["cre"]
    else:
        return ["cre"]