How to use the betterbib.journal_abbrev 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 / test / test_tools.py View on Github external
def test_journal_name():
    shrt = pybtex.database.Entry(
        "article", fields={"journal": "SIAM J. Matrix Anal. Appl."}
    )
    lng = pybtex.database.Entry(
        "article",
        fields={"journal": "SIAM Journal on Matrix Analysis and Applications"},
    )

    tmp = betterbib.journal_abbrev({"key": lng})
    assert tmp["key"].fields["journal"] == shrt.fields["journal"]

    lng = pybtex.database.Entry(
        "article",
        fields={"journal": "SIAM Journal on Matrix Analysis and Applications"},
    )
    tmp = betterbib.journal_abbrev({"key": shrt}, long_journal_names=True)
    assert tmp["key"].fields["journal"] == lng.fields["journal"]
github nschloe / betterbib / test / test_journal_abbrev.py View on Github external
def test_custom_abbrev():
    infile = tempfile.NamedTemporaryFile().name
    super_short = '{"PNAS": "' + PNAS_ABBREV + '"}'
    with open(infile, "w") as f:
        f.write(super_short)

    entries = make_fake_entry("PNAS")
    abbreviated = betterbib.journal_abbrev(entries, custom_abbrev=infile)
    assert abbreviated["foo"].fields["journal"] == PNAS_ABBREV

    super_short = '{"' + FULL_PNAS + '": "PNAS"}'
    with open(infile, "w") as f:
        f.write(super_short)

    entries = make_fake_entry(FULL_PNAS)
    abbreviated = betterbib.journal_abbrev(entries, custom_abbrev=infile)
    assert abbreviated["foo"].fields["journal"] == "PNAS"
github nschloe / betterbib / test / test_journal_abbrev.py View on Github external
def test_standard_abbrev_long():
    journals = [FULL_PNAS]
    abbrevs = [PNAS_ABBREV]
    for journal, abbrev in zip(journals, abbrevs):
        entries = make_fake_entry(abbrev)
        abbreviated = betterbib.journal_abbrev(entries, long_journal_names=True)
        assert abbreviated["foo"].fields["journal"] == journal
github nschloe / betterbib / test / test_tools.py View on Github external
shrt = pybtex.database.Entry(
        "article", fields={"journal": "SIAM J. Matrix Anal. Appl."}
    )
    lng = pybtex.database.Entry(
        "article",
        fields={"journal": "SIAM Journal on Matrix Analysis and Applications"},
    )

    tmp = betterbib.journal_abbrev({"key": lng})
    assert tmp["key"].fields["journal"] == shrt.fields["journal"]

    lng = pybtex.database.Entry(
        "article",
        fields={"journal": "SIAM Journal on Matrix Analysis and Applications"},
    )
    tmp = betterbib.journal_abbrev({"key": shrt}, long_journal_names=True)
    assert tmp["key"].fields["journal"] == lng.fields["journal"]
github nschloe / betterbib / test / test_journal_abbrev.py View on Github external
def test_custom_abbrev_long():
    infile = tempfile.NamedTemporaryFile().name
    super_short = '{"' + FULL_PNAS + ': "PNAS"}'
    with open(infile, "w") as f:
        f.write(super_short)

    entries = make_fake_entry(PNAS_ABBREV)
    abbreviated = betterbib.journal_abbrev(entries, long_journal_names=True)
    assert abbreviated["foo"].fields["journal"] == FULL_PNAS
github nschloe / betterbib / test / test_journal_abbrev.py View on Github external
def test_standard_abbrev():
    journals = [FULL_PNAS]
    abbrevs = [PNAS_ABBREV]
    for journal, abbrev in zip(journals, abbrevs):
        entries = make_fake_entry(journal)
        abbreviated = betterbib.journal_abbrev(entries)
        assert abbreviated["foo"].fields["journal"] == abbrev