Re: Keyless BibTeX entries no longer being parsed

"Frédéric Gobry" <[email protected]> Tue, 6 Mar 2007 20:36:13 +0000
Newsgroups gmane.comp.gnome.apps.pybliographer
Message-ID <[email protected]>
2007/3/6, Hamish Lawson <hbl-T7IeVJDLM9PtNP1Hz/[email protected]>:
> I previously downloaded the tar file for 1.3.3 from Sourceforge.
> Recently I downloaded patch 76 (to take advantage of the semantic ISI
> parser that had been added). Now I'm finding that BibTeX files without
> citation keys are now failing to be parsed.

Is this from a valid source? The idea with the parsers in 1.3 is that
they should do what's correct by default, and let you override if you
need something more specific. In you case, the simplest thing would be
to derive from the parser and overload Reader.record_end(), which is
when the record gets its bibtex key:

from Pyblio.Parers.Semantic import BibTeX

class MyParserForMissingKeys(BibTeX.Reader)
  def record_end(self):
    if self.key is None:
      ... do sth specific
    else:
      BibTeX.Reader.record_end(self)

Hope this helps.

>
> Previously the following entry would be successfully parsed:
>
> ----
> @ARTICLE{
>         AUTHOR             = {Fred Smith},
>         JOURNAL            = {Some Journal},
>         MONTH              = sep,
>         NUMBER             = {40},
>         PAGES              = {21--23},
>         TITLE              = {Something about Nothing},
>         YEAR               = {1993},
> }
> ----
>
> But now it produces the following error:
>
> ----
> Traceback (most recent call last):
>   File "dev/test_endnote_import.py", line 15, in ?
>     reader.parse(publication_file, db)
>   File "/usr/local/python/lib/python2.4/site-packages/pybliographer-1.3.3-py2.4.egg/Pyblio/Parsers/Syntax/BibTeX/__init__.py",
> line 391, in parse
>     self.record_parse (data)
>   File "/usr/local/python/lib/python2.4/site-packages/pybliographer-1.3.3-py2.4.egg/Pyblio/Parsers/Syntax/BibTeX/__init__.py",
> line 367, in record_parse
>     self.record_end ()
>   File "/usr/local/python/lib/python2.4/site-packages/pybliographer-1.3.3-py2.4.egg/Pyblio/Parsers/Semantic/BibTeX.py",
> line 58, in record_end
>     self.id_add('id', self.key)
>   File "/usr/local/python/lib/python2.4/site-packages/pybliographer-1.3.3-py2.4.egg/Pyblio/Parsers/Syntax/BibTeX/__init__.py",
> line 94, in id_add
>     self.record [field] = [Attribute.ID(stream.flat())]
> AttributeError: 'NoneType' object has no attribute 'flat'
> ----
>
> The entry is successfully parsed if a citation key is provided:
>
> @ARTICLE{fred-smith,
> ...
>
>
> Hamish
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Pybliographer-general mailing list
> Pybliographer-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/pybliographer-general
>
>


-- 
Frédéric

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV