In some of my bibtex files I use string variables for journal/conference names, in order to later decide between the full name or the abbreviation (using different bibfiles defining those strings). Here is an example entry:
@Article{ HT2017,
title = "Trace inclusion for one-counter nets revisited ",
journal = tcs,
volume = "11174",
year = "2017",
issn = "0304-3975",
doi = "https://doi.org/10.1016/j.tcs.2017.05.009",
author = "Piotr Hofman and Patrick Totzke",
keywords = {mine,OCN}
}
@string{tcs = "Theoretical Computer Science"}
Importing this (no matter if I pass both files or just the one with the bibtex entry) gives:
xapers import refs.bib
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 288, in substitute_macro
return self.macros[name]
File "/usr/lib/python3/dist-packages/pybtex/utils.py", line 154, in __getitem__
return self._dict[key.lower()]
KeyError: 'tcs'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/xapers/bibtex.py", line 60, in __init__
bibdata = parser.parse_file(bibtex)
File "/usr/lib/python3/dist-packages/pybtex/database/input/__init__.py", line 51, in parse_file
self.parse_stream(f)
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 385, in parse_stream
return self.parse_string(text)
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 372, in parse_string
for entry in entry_iterator:
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 185, in parse_bibliography
self.handle_error(error)
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 358, in handle_error
report_error(error)
File "/usr/lib/python3/dist-packages/pybtex/errors.py", line 77, in report_error
raise exception
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 183, in parse_bibliography
yield tuple(self.parse_command())
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 216, in parse_command
self.handle_error(error)
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 358, in handle_error
report_error(error)
File "/usr/lib/python3/dist-packages/pybtex/errors.py", line 77, in report_error
raise exception
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 213, in parse_command
parse_body(body_end)
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 232, in parse_entry_body
self.parse_entry_fields()
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 240, in parse_entry_fields
self.parse_field()
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 253, in parse_field
self.parse_value()
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 264, in parse_value
value_parts.append(self.parse_value_part())
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 280, in parse_value_part
value_part = self.substitute_macro(token.value)
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 291, in substitute_macro
self.handle_error(UndefinedMacro(name, self))
File "/usr/lib/python3/dist-packages/pybtex/database/input/bibtex.py", line 358, in handle_error
report_error(error)
File "/usr/lib/python3/dist-packages/pybtex/errors.py", line 77, in report_error
raise exception
pybtex.database.input.bibtex.UndefinedMacro: undefined string in line 4: tcs
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/xapers", line 11, in <module>
load_entry_point('xapers==0.8.2', 'console_scripts', 'xapers')()
File "/usr/lib/python3/dist-packages/xapers/__main__.py", line 221, in main
cli.importbib(db, bibfile, tags=tags)
File "/usr/lib/python3/dist-packages/xapers/cli.py", line 319, in importbib
for entry in sorted(Bibtex(bibfile), key=lambda entry: entry.key):
File "/usr/lib/python3/dist-packages/xapers/bibtex.py", line 61, in __init__
except TokenRequired as e:
NameError: name 'TokenRequired' is not defined
In some of my bibtex files I use string variables for journal/conference names, in order to later decide between the full name or the abbreviation (using different bibfiles defining those strings). Here is an example entry:
A separate file defines the string "tcs":
Importing this (no matter if I pass both files or just the one with the bibtex entry) gives: