def _customizations_latex(record): """ This function curstumizes record for bibtex. See bibtexparser lib for more info. """ record = customization.page_double_hyphen(record) record = customization.homogeneize_latex_encoding(record) record = customization.author(record) return record
def _customizations_unicode(record): """ This function curstumizes record for raw style. See bibtexparser lib for more info. """ record = customization.page_double_hyphen(record) record = customization.convert_to_unicode(record) record = customization.author(record) return record
def _customizations_latex(record): """ This function curstumizes record for bibtex. See bibtexparser lib for more info. """ record = customization.page_double_hyphen(record) record = customization.homogenize_latex_encoding(record) record = customization.author(record) return record
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
def td_biblio_customization(record): """ Customize BibTex records parsing """ # Convert crapy things to latex record = to_latex(record) # and then to unicode record = bp_customization.convert_to_unicode(record) record = bp_customization.type(record) record = bp_customization.author(record) record = bp_customization.editor(record) record = bp_customization.page_double_hyphen(record) return record
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
def _parse_bib_entry(entry): """ Customization function for bibtexparser. :param entry: bibtex record to modify :return bibtex record """ if CONVERT_TO_UNICODE: entry = bib_custom.convert_to_unicode(entry) entry = bib_custom.author(entry) entry = bib_custom.editor(entry) entry = bib_custom.keyword(entry) entry = bib_custom.page_double_hyphen(entry) return entry
def customizations(record): """Use some functions delivered by the library :param record: a record :returns: -- customized record """ record = convert_to_unicode(record) # record = type(record) record = author(record) record = editor(record) # record = journal(record) # Do not use! # record = keyword(record) # record = link(record) record = page_double_hyphen(record) # record = 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
def customizations(record): ''' Use some customizations for bibtexparser Args: record: A record Returns: record: Customized record ''' record = convert_to_unicode(record) # record = type(record) record = author(record) record = editor(record) # record = journal(record) # Do not use! # record = keyword(record) # record = link(record) record = page_double_hyphen(record) # record = doi(record) return record
def customizations(record): """Use some functions delivered by the library :param record: a record :returns: -- customized record """ # record = homogenize_latex_encoding(record) # record = customization.type(record) record = customization.author(record) record = editor(record) # record = editor(record) # # print(record) # # This makes it a dict # # record = journal(record) # # print(record) # record = keyword(record) # record = link(record) record = customization.page_double_hyphen(record) # record = doi(record) return record
def customizations(record): """Use some functions delivered by the library Args: record (dict): record dict. Returns: record (dict): the modified record """ record = bibcus.type(record) record = bibcus.author(record) #record = bibcus.editor(record) #record = bibcus.journal(record) record = bibcus.keyword(record) #record = bibcus.link(record) record = bibcus.page_double_hyphen(record) #record = bibcus.doi(record) record = splitFields(record, 'folder') record = splitFields(record, 'url', '\n') record = splitFields(record, 'file', ',|;|\n') record = getPublication(record) return record
def customizations(record): """Use some functions delivered by the library :param record: a record :returns: -- customized record """ #record = type(record) #record = author(record) # would split the 'author' field into an array (also see splitname(string singlename) and getnames(list names)) #record = editor(record) record = page_double_hyphen(record) #record = journal(record) #record = keyword(record) #record = link(record) #record = doi(record) #record = homogenize_latex_encoding(record) # NOTE(Alin): convert_to_unicode(record) seems to change valid LaTeX in the .bib file like \url{...} to Unicode junk, which we don't want. # Furthermore, we want to keep the LaTeX when copying the BibTeX to the clipboard. #record = convert_to_unicode(record) return record
def cust2(record): record = customization.author(record) record = customization.page_double_hyphen(record) record = customization.homogenize_latex_encoding(record) return record
def test_page_double_hyphen_nothing(self): record = {'pages': '12 24'} result = page_double_hyphen(record) expected = {'pages': '12 24'} self.assertEqual(result, expected)
def test_page_double_hyphen_space(self): record = {'pages': '12 - 24'} result = page_double_hyphen(record) expected = {'pages': '12--24'} self.assertEqual(result, expected)
def test_page_double_hyphen_alreadyOK(self): record = {'pages': '12--24'} result = page_double_hyphen(record) expected = record self.assertEqual(result, expected)
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