示例#1
0
def _extract(text):
    # convert to utf8 and generate a dictionary
    try:
        try:
            strings, entries = bibtexparse.bibtexload(
                unicode(text, "utf-8").splitlines())
        except TypeError:
            strings, entries = bibtexparse.bibtexload(text.splitlines())
    except UnicodeDecodeError:
        raise TracError("A UnicodeDecodeError occured while loading the"
                        "data. Try to save the file in UTF-8 encoding.")
    crossRef = []
    for k, bib in entries.iteritems():
        bibtexparse.replace_abbrev(bib, def_strings)
        bibtexparse.replace_abbrev(bib, strings)
        if bib.get('crossref'):
            crossRef.append(k)
    # merging the entry and its cross-reference into one dictionary
    for k in crossRef:
        if entries[k]['crossref'] in entries:
            ref = entries[entries[k]['crossref']].copy()
            ref.update(entries[k])
            entries[k] = ref
            print entries[k]
    return entries
示例#2
0
def _extract(text):
    # convert to utf8 and generate a dictionary
    try:
        try:
            strings, entries = bibtexparse.bibtexload(
                unicode(text, "utf-8").splitlines())
        except TypeError:
            strings, entries = bibtexparse.bibtexload(text.splitlines())
    except UnicodeDecodeError:
        raise TracError("A UnicodeDecodeError occured while loading the"
                        "data. Try to save the file in UTF-8 encoding.")
    crossRef = []
    for k, bib in entries.iteritems():
        bibtexparse.replace_abbrev(bib, def_strings)
        bibtexparse.replace_abbrev(bib, strings)
        if bib.get('crossref'):
            crossRef.append(k)
    # merging the entry and its cross-reference into one dictionary
    for k in crossRef:
        if entries[k]['crossref'] in entries:
            ref = entries[entries[k]['crossref']].copy()
            ref.update(entries[k])
            entries[k] = ref
            print entries[k]
    return entries
示例#3
0
def extract_entries(text):
  strings,bibdb=bibtexparse.bibtexload(text.splitlines())
  for k,bib in bibdb.iteritems():
      bibtexparse.replace_abbrev(bib,def_strings)
      bibtexparse.replace_abbrev(bib,strings)
      for key,value in bib.iteritems() :
        bib[key] = replace_tags(value)
  return bibdb
示例#4
0
def extract_entries(text):
    strings, bibdb = bibtexparse.bibtexload(text.splitlines())
    for k, bib in bibdb.iteritems():
        bibtexparse.replace_abbrev(bib, def_strings)
        bibtexparse.replace_abbrev(bib, strings)
        for key, value in bib.iteritems():
            bib[key] = replace_tags(value)
    return bibdb