当前位置: 首页>>代码示例>>Python>>正文


Python BibTexWriter.order_entries_by方法代码示例

本文整理汇总了Python中bibtexparser.bwriter.BibTexWriter.order_entries_by方法的典型用法代码示例。如果您正苦于以下问题:Python BibTexWriter.order_entries_by方法的具体用法?Python BibTexWriter.order_entries_by怎么用?Python BibTexWriter.order_entries_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bibtexparser.bwriter.BibTexWriter的用法示例。


在下文中一共展示了BibTexWriter.order_entries_by方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sort_missing_field

# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import order_entries_by [as 别名]
 def test_sort_missing_field(self):
     bib_database = BibDatabase()
     bib_database.entries = [{'ID': 'b',
                              'ENTRYTYPE': 'article',
                              'year': '2000'},
                             {'ID': 'c',
                              'ENTRYTYPE': 'book',
                              'year': '2010'},
                             {'ID': 'a',
                              'ENTRYTYPE': 'book'}]
     writer = BibTexWriter()
     writer.order_entries_by = ('year', )
     result = bibtexparser.dumps(bib_database, writer)
     expected = "@book{a\n}\n\[email protected]{b,\n year = {2000}\n}\n\[email protected]{c,\n year = {2010}\n}\n\n"
     self.assertEqual(result, expected)
开发者ID:gpoo,项目名称:python-bibtexparser,代码行数:17,代码来源:test_bibtexwriter.py

示例2: _cleanupBibTex

# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import order_entries_by [as 别名]
    def _cleanupBibTex(self, count):
        """ Clean up bibtex and ensure uniform look. """
        import bibtexparser
        from bibtexparser.bparser import BibTexParser
        parser = BibTexParser()
        parser.customization = homogeneize_latex_encoding
        bib = bibtexparser.loads(self.refs, parser=parser)

        # save results
        from bibtexparser.bwriter import BibTexWriter
        writer = BibTexWriter()
        writer.contents = ['entries']
        writer.indent = '    '
        writer.order_entries_by = ('id')
        self.number = len(bib.entries)
        self.refs = bibtexparser.dumps(bib, writer)
开发者ID:siudej,项目名称:Cite,代码行数:18,代码来源:fetch.py

示例3: write_bib

# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import order_entries_by [as 别名]
def write_bib(db, order=False):
    """
    Write bibtex string.

    Args:
        db (BibDatabase): database object to dump..
        order (bool): whether to reorder entries upon writing.

    Returns:
        The dumped string.
    """

    # Custom writer
    writer = BibTexWriter()
    writer.indent = '\t'
    writer.order_entries_by = None

    # Replace month by numeric value
    for entry in db.entries:
        if 'month' in entry and entry['month'] in MONTHS:
            entry['month'] = '{:02d}'.format(MONTHS.index(entry['month']) + 1)

    if order:
        # Manual sort
        order_entries_by = ('year', 'author', 'ID')
        sort_entries(db, order_entries_by)

    if not config.use_utf8_characters:
        db.entries = [nomenclature.encode_ascii_latex(entry) for entry in db.entries]

    if config.protect_uppercase:
        for entry in db.entries:
            entry["title"] = latex.protect_uppercase(entry["title"])

    # Write bib string
    return writer.write(db)
开发者ID:jdumas,项目名称:autobib,代码行数:38,代码来源:utils.py

示例4: test_sort_type_id

# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import order_entries_by [as 别名]
 def test_sort_type_id(self):
     writer = BibTexWriter()
     writer.order_entries_by = ('ENTRYTYPE', 'ID')
     result = bibtexparser.dumps(self.bib_database, writer)
     expected = "@article{b\n}\n\[email protected]{a\n}\n\[email protected]{c\n}\n\n"
     self.assertEqual(result, expected)
开发者ID:gpoo,项目名称:python-bibtexparser,代码行数:8,代码来源:test_bibtexwriter.py

示例5: test_sort_none

# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import order_entries_by [as 别名]
 def test_sort_none(self):
     writer = BibTexWriter()
     writer.order_entries_by = None
     result = bibtexparser.dumps(self.bib_database, writer)
     expected = "@article{b\n}\n\[email protected]{c\n}\n\[email protected]{a\n}\n\n"
     self.assertEqual(result, expected)
开发者ID:gpoo,项目名称:python-bibtexparser,代码行数:8,代码来源:test_bibtexwriter.py

示例6: BibTexWriter

# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import order_entries_by [as 别名]
        },
    },
    'loggers': {
        '': {
            'handlers': ['default'],
            'level': 'ERROR',
            'formatter': 'standard',
            'propagate': True
        }
    }
})

writer = BibTexWriter()
writer.contents = ['comments', 'entries']
writer.indent = '  '
writer.order_entries_by = ('ENTRYTYPE', 'author', 'year')

def create_id(t, year, title):
	return str(t) + "_" + str(year) + "_" + str(space_to_underscore(title))

def pdf(pdf_files, shared_pdf, bibtex_folder, bibtex_files, gscholar):
	for pdf in pdf_files:
		txt = re.sub("\W", " ", gs.convert_pdf_to_txt(pdf)).lower()
		#Research determined that the cutting of 35 words gives the 
		#highest accuracy
		words = txt.strip().split()[:35]
		words = " ".join(words)		
		print words
		if gscholar == True:
			bib = load(gs.pdflookup(pdf, all, gs.FORMAT_BIBTEX)[0])
			keys = bib.entries[0].keys()
开发者ID:Juvawa,项目名称:bib2web,代码行数:33,代码来源:main.py

示例7: len

# 需要导入模块: from bibtexparser.bwriter import BibTexWriter [as 别名]
# 或者: from bibtexparser.bwriter.BibTexWriter import order_entries_by [as 别名]
    bib_database = bibtexparser.load(bibtex_file, parser=parser)

if bib_database :
    now = datetime.datetime.now()
    success = "{0} Loaded {1} found {2} entries".format(now, input_b, len(bib_database.entries))
    print(success)
else :
    now = datetime.datetime.now()
    errs = "{0} Failed to read {1}".format(now, input_b)
    print(errs)
    sys.exit(errs)

bibtex_str = None
if bib_database:
    writer = BibTexWriter()
    writer.order_entries_by = ('author', 'year', 'type')
    bibtex_str = bibtexparser.dumps(bib_database, writer)
    #print(str(bibtex_str))
    with open(output_b, "w") as text_file:
        #print >> text_file, bibtex_str
        print(bibtex_str, file=text_file)

if bibtex_str:
    now = datetime.datetime.now()
    success = "{0} Wrote to {1} with len {2}".format(now, output_b, len(bibtex_str))
    print(success)
else:
    now = datetime.datetime.now()
    errs = "{0} Failed to write {1}".format(now, output_b)
    print(errs)
    sys.exit(errs)
开发者ID:ucjtwbo,项目名称:thesis,代码行数:33,代码来源:clean_bib.py


注:本文中的bibtexparser.bwriter.BibTexWriter.order_entries_by方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。