jrollins / xapers

Personal journal article management and indexing system
https://gitlab.com/jrollins/xapers
Other
7 stars 3 forks source link

import fails #3

Open pazz opened 6 years ago

pazz commented 6 years ago

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}
}

A separate file defines the string "tcs":

@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
pfalcon commented 3 years ago

Friendly ping to @jrollins to assess how active the project is.

jrollins commented 3 years ago

Hi @pfalcon, yes this project is actively maintained. Not too much development work has happened in the last couple of years, but I would actually like to push out a new release soon.

Are you experiencing the issue reported in this report?

pfalcon commented 3 years ago

Are you experiencing the issue reported in this report?

No, I find myself in the state of deep amazement that I missed this project, given that it's even shipped by Debian/Ubuntu. So, I had to write my own thingy instead (https://github.com/pfalcon/papersman). I swear I always do a searching homework before embarking to potentially duplicate effort. Now I however would like to be sure that this project is maintained before considering it as an alternative, or extension, to mine, hence then ping. And thanks for reply (sorry of course for hijacking this issue, but given that it never received any comments anyway, receiving some, even if not directly related, can be considered "net positive" with some stretch ;-) ).

jrollins commented 3 years ago

@pfalcon Well I hope you find xapers useful! We appreciate any feed back, and development help.