本文整理汇总了Python中bibtexparser.bwriter.BibTexWriter._entry_to_bibtex方法的典型用法代码示例。如果您正苦于以下问题:Python BibTexWriter._entry_to_bibtex方法的具体用法?Python BibTexWriter._entry_to_bibtex怎么用?Python BibTexWriter._entry_to_bibtex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bibtexparser.bwriter.BibTexWriter
的用法示例。
在下文中一共展示了BibTexWriter._entry_to_bibtex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import _entry_to_bibtex [as 别名]
def parse(bibfile):
with open(bibfile) as bibtex_file:
writer = BibTexWriter()
bib_database = bibtexparser.load(bibtex_file)
for entry in bib_database.entries:
print "\t-"
print "\t\tlayout: paper"
print "\t\tpaper-type: "+ preprocess(entry["type"])
print "\t\tyear: " + preprocess(entry["year"])
print "\t\tselected: no"
print "\t\ttitle: >\n\t\t\t"+preprocess(entry["title"])
print "\t\tauthors: "+ parseauthors(preprocess(entry["author"])).encode('UTF8')
print "\t\timg: "
print "\t\tvenue: "
if("pages" in entry.keys()):
print "\t\tpages: "+preprocess(entry["pages"])
if("booktitle" in entry.keys()):
print "\t\tbooktitle: "+preprocess(entry["booktitle"])
if("journal" in entry.keys()):
print "\t\tjournal: "+preprocess(entry["journal"])
if("url" in entry.keys()):
print "\t\tdoc-url: "+preprocess(entry["url"])
else:
print "\t\tdoc-url: "
if("abstract" in entry.keys()):
print "\t\tabstract: >\n\t\t\t" + preprocess(entry["abstract"]).encode('UTF8')
print "\t\tbibtex: >\n\t\t\t"+ writer._entry_to_bibtex(entry).replace("\n","\n\t\t\t").encode('UTF8')
示例2: write_bibtex_dict
# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import _entry_to_bibtex [as 别名]
def write_bibtex_dict (stream, entries):
"""bibtexparser.write converts the entire database to one big string and
writes it out in one go. I'm sure it will always all fit in RAM but some
things just will not stand.
"""
from bibtexparser.bwriter import BibTexWriter
writer = BibTexWriter ()
writer.indent = ' '
writer.entry_separator = ''
first = True
for rec in entries:
if first:
first = False
else:
stream.write ('\n')
stream.write (writer._entry_to_bibtex (rec))
示例3: bibTexIn
# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import _entry_to_bibtex [as 别名]
def bibTexIn(filename):
#load database into bibtexdatabase object
with codecs.open(filename, 'r', 'utf-8') as bibtex_file:
parser = BibTexParser()
parser.customization = convert_to_unicode
bibtex_database = bibtexparser.load(bibtex_file,parser)
#load all the keys we want to add into the dialectsDB database
dbbibtexkeys = [x.bibTexKey for x in BiblioEntryBibTex.objects.all()]
btdbdict = bibtex_database.entries_dict
for item in dbbibtexkeys:
try:
currentbtitem = btdbdict[item]
currentBEobject = BiblioEntryBibTex.objects.get(bibTexKey=item)
writer = BibTexWriter()
bibtexofentry = writer._entry_to_bibtex(currentbtitem)
currentBEobject.fullBibtex = bibtexofentry
print("Currently saving: {}".format(item))
currentBEobject.save() #The saving function should put the relevant info into the other fields
except KeyError:
print("No bibliography entry for: {}".format(item))
示例4: toString
# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import _entry_to_bibtex [as 别名]
def toString(e):
writer = BibTexWriter()
writer.indent = ' ' # indent entries with 4 spaces instead of one
writer.comma_first = True # place the comma at the beginning of the line
return writer._entry_to_bibtex(e)