示例#1
0
def customizations(record):
    record = bib_type(record)
    record = author(record)
    record = editor(record)
    record = journal(record)
    record = keyword(record)
    record = link(record)
    record = page_double_hyphen(record)
    record = doi(record)
    return record
示例#2
0
def bibtex_cleaner(entry):
    entry = clean.keyword(entry)
    if entry.get('keyword'):
        entry['keyword'] = ','.join(entry['keyword']).lower()
    # print(entry.get('keyword'))
    entry = clean.page_double_hyphen(entry)
    entry = clean.convert_to_unicode(entry)
    # entry = clean.add_plaintext_fields(entry)

    entry = clean.link(entry)
    entry = clean.doi(entry)
    # print(entry.get('keyword'))

    return entry
示例#3
0
def customizations(record):
    """Use some functions delivered by the library

    :param record: a record
    :returns: -- customized record

    """
    record = bc.convert_to_unicode(record)
    record = bc.type(record)  # lowercase
    record = bc.author(record)
    record = bc.editor(record)
    record = bc.journal(record)
    record = bc.keyword(record)
    record = bc.link(record)
    record = bc.page_double_hyphen(record)
    record = bc.doi(record)
    return record
def customizations(record):
    """Use some functions delivered by the library

    :param record: a record
    :returns: -- customized record

    """
    record = bc.convert_to_unicode(record)
    record = bc.type(record)    # lowercase
    record = bc.author(record)
    record = bc.editor(record)
    record = bc.journal(record)
    record = bc.keyword(record)
    record = bc.link(record)
    record = bc.page_double_hyphen(record)
    record = bc.doi(record)
    return record
示例#5
0
def custom(record):
    record = c.type(record)
    record = c.author(record)
    record = c.editor(record)
    record = c.journal(record)
    record = c.keyword(record)
    record = c.link(record)
    record = c.doi(record)
    tags = set()

    if 'tags' in record:
        tags.update([i.strip() for i in re.split(',|;', record["tags"].replace('\n', ''))])
    if "keywords" in record:
        tags.update([i.strip() for i in re.split(',|;', record["keywords"].replace('\n', ''))])
    if "mendeley-tags" in record:
        tags.update([i.strip() for i in re.split(',|;', record["mendeley-tags"].replace('\n', ''))])

    record['tags'] = tags
    record['p_authors'] = []
    if 'author' in record:
        record['p_authors'] = [c.splitname(x, False) for x in record['author']]
    return record
def clean_full(record):
    record = c.type(record)
    record = c.author(record)
    record = c.editor(record)
    record = c.journal(record)
    record = c.keyword(record)
    record = c.link(record)
    record = c.doi(record)
    tags = set()

    if 'tags' in record:
        tags.update([
            i.strip()
            for i in re.split(',|;', record["tags"].replace('\n', ''))
        ])
    if "keywords" in record:
        tags.update([
            i.strip()
            for i in re.split(',|;', record["keywords"].replace('\n', ''))
        ])
    if "mendeley-tags" in record:
        tags.update([
            i.strip()
            for i in re.split(',|;', record["mendeley-tags"].replace('\n', ''))
        ])

    record['tags'] = tags
    record['p_authors'] = []

    if 'author' in record:
        record['p_authors'] += [x.split(' and ') for x in record['author']]

    if 'editor' in record:
        record['p_authors'] += [
            c.splitname(x, False) for x in record['editor']
        ]

    return record
示例#7
0
def customize(record):
    def fix_newlines(record):
        for key, value in record.items():
            if key in 'url':
                record[key] = value.replace("\n", "")
            if key not in ('author', 'url', 'editor'):
                value = value.replace("\n", " ")
                record[key] = value.replace(r"\par", "\n\n")
        return record

    record = fix_newlines(record)
    record = customization.type(record)
    record = customization.convert_to_unicode(record)

    def split_author(record):
        if 'author' in record:
            authors = []
            for author in record['author']:
                lastname, firstname = author.split(", ")
                authors.append(Author(firstname, lastname))
            record['author'] = authors
        return record

    def parse_kind(kind, record):
        if kind in record and record[kind]:
            remove_translate_table = str.maketrans('', '', ', .')
            # record_id determines the name of the PDF
            # it's been hard-coded in the view:
            # layouts/partials/publications_icons.html
            # ----> this might want to be refactored
            record_id = record[kind].translate(remove_translate_table)
            record[kind] = {'name': record[kind], 'ID': record_id}
        return record

    record = customization.author(record)
    record = customization.journal(record)
    record = customization.keyword(record)
    record = customization.link(record)
    record = customization.doi(record)
    record = customization.page_double_hyphen(record)
    record = split_author(record)

    for kind in ('booktitle', 'series'):
        record = parse_kind(kind, record)

    def pdf_is_there(record):
        #print(record["ID"])
        filename = record["ID"] + ".pdf"
        path_to_file = os.path.join(LOCAL_PDF_VAULT, filename)
        print(path_to_file)
        if os.path.isfile(path_to_file):
            print("\t PDF found!")
        else:
            print("\t NO PDF!!!")
            record["paper"] = "no"
        return record

    if ("paper" in record.keys() and record["paper"] == "yes"):
        #print(record)
        return pdf_is_there(record)

    return record