How to use the betterbib.tools.write function in betterbib

To help you get started, we’ve selected a few betterbib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / betterbib / betterbib / cli / journal_abbrev.py View on Github external
def main(argv=None):
    parser = _get_parser()
    args = parser.parse_args(argv)

    data = bibtex.Parser().parse_file(args.infile)
    d = dict(data.entries.items())

    d = journal_abbrev(d, args.long_journal_names, args.extra_abbrev_file)

    tools.write(d, args.outfile, "braces", tab_indent=False)
github nschloe / betterbib / betterbib / cli / sync.py View on Github external
def main(argv=None):
    parser = _get_parser()
    args = parser.parse_args(argv)

    data = bibtex.Parser().parse_file(args.infile)
    # data.entries.items() is a list of tuples, the first item being the BibTeX key.
    input_dict = dict(data.entries.items())

    out = sync(
        input_dict, args.source, args.long_journal_name, args.num_concurrent_requests
    )

    write(out, args.outfile, "braces", tab_indent=False)
github nschloe / betterbib / betterbib / cli / format.py View on Github external
data = bibtex.Parser().parse_file(args.infile)

    if args.drop:
        data = tools.filter_fields(data, args.drop)

    # Use an ordered dictionary to make sure that the entries are written out
    # sorted by their BibTeX key if demanded.
    tuples = data.entries.items()
    if args.sort_by_bibkey:
        tuples = sorted(data.entries.items())

    d = dict(tuples)

    d = adapt_doi_urls(d, args.doi_url_type)

    tools.write(d, args.outfile, args.delimeter_type, tab_indent=args.tab_indent)
github nschloe / betterbib / betterbib / cli / full.py View on Github external
args = parser.parse_args(argv)

    # Make sure that the entries are written out sorted by their BibTeX key if demanded.
    data = bibtex.Parser().parse_file(args.infile)
    tuples = data.entries.items()
    if args.sort_by_bibkey:
        tuples = sorted(data.entries.items())

    d = dict(tuples)

    d = sync(d, args.source, args.long_journal_names, args.num_concurrent_requests)
    d = adapt_doi_urls(d, args.doi_url_type)
    d = tools.sanitize_title(d)
    d = journal_abbrev(d, args.long_journal_names, args.extra_abbrev_file)

    tools.write(d, args.outfile, args.delimeter_type, tab_indent=args.tab_indent)