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 cust2(record): record = customization.author(record) record = customization.page_double_hyphen(record) record = customization.homogenize_latex_encoding(record) return record
(lambda split: (split[0] if split else "a") + str(work.year))(work.authors.split()))), ], "<middle>": [ (None, _work_to_bibtex_middle), ], "<ignore>": lambda: BIBTEX_IGNORE_FIELDS + ["place", "place1"], "<use>": lambda: WORK_FIELDS, "<result>": lambda work, new, current: ([ consume(new, "_name"), consume(new, "_acronym"), homogenize_latex_encoding(new) if consume(new, "_homogeneize") else new, ][-1]), "name": ["title"], "authors": ["author"], "local": ["address"], "organization": ["publisher"], "pp": ["pages"], "entrytype": ["ENTRYTYPE"], } ### Snowballing Forms def convert_citation_text_lines_to_info(text): """Convert lines of format [N] author name place other year' to Info object
def test_homogenize(self): record = {'toto': 'à {\`a} \`{a}'} result = homogenize_latex_encoding(record) expected = {'toto': '{\`a} {\`a} {\`a}'} self.assertEqual(result, expected)
def work_to_bibtex_entry(work, name=None, homogeneize=True, acronym=False): """Convert work to BibTeX entry dict for bibtexparser Doctest: .. doctest:: >>> reload() >>> murta2014a = work_by_varname("murta2014a") >>> result = work_to_bibtex_entry(murta2014a) >>> list(result) ['ID', 'address', 'publisher', 'pages', 'booktitle', 'author', 'title', 'year', 'ENTRYTYPE'] >>> result['ID'] 'murta2014a' >>> result['address'] 'Cologne, Germany' >>> result['publisher'] 'Springer' >>> result['pages'] '71--83' >>> result['booktitle'] 'International Provenance and Annotation Workshop' >>> result['author'] # doctest: +ELLIPSIS 'Murta, Leonardo and Braganholo, Vanessa and ... and Freire, Juliana' >>> result['title'] 'no{W}orkflow: capturing and analyzing provenance of scripts' >>> result['year'] '2014' >>> result['ENTRYTYPE'] 'inproceedings' Custom name: >>> result = work_to_bibtex_entry(murta2014a, name="other") >>> list(result) ['ID', 'address', 'publisher', 'pages', 'booktitle', 'author', 'title', 'year', 'ENTRYTYPE'] >>> result['ID'] 'other' Use acronym for place name: >>> result = work_to_bibtex_entry(murta2014a, acronym=True) >>> list(result) ['ID', 'address', 'publisher', 'pages', 'booktitle', 'author', 'title', 'year', 'ENTRYTYPE'] >>> result['booktitle'] 'IPAW' """ options = config.WORK_FIELDS ignore = config.BIBTEX_IGNORE_FIELDS mapa = config.WORK_BIBTEX_MAP if not name: if hasattr(work, 'metakey'): name = work.metakey else: split = work.authors.split() name = split[0].replace(",", "") if split else "a" name += str(work.year) if config.DEBUG_FIELDS: for key in dir(work): if not match_any(key, options) and not match_any(key, ignore): print(work.display, work.year, key) result = OrderedDict() result["ID"] = name for key in reversed(options): if hasattr(work, key) and not match_any(key, ignore): value = getattr(work, key) is_conference = (key == "place" and acronym and value.type == "Conference" and not value.acronym.startswith("<")) if is_conference: value = value.acronym name = mapa.get(key, lambda x: key)(work) if name: result[name] = str(value) if not "ENTRYTYPE" in result: result["ENTRYTYPE"] = "misc" if hasattr(work, "notes"): result["year"] += " [{}]".format(work.notes) if homogeneize: result = homogenize_latex_encoding(result) return result