Exemplo n.º 1
0
import os
import re

from zope.component import getUtility, ComponentLookupError

from bibliograph.parsing.parsers.base import BibliographyParser
from bibliograph.rendering.interfaces import IBibTransformUtility

from bibliograph.core.utils import _encode, _decode
from bibliograph.core.bibutils import _hasCommands
from bibliograph.core.encodings import _latex2utf8enc_mapping
from bibliograph.core.encodings import _latex2utf8enc_mapping_simple

_encoding = 'utf-8'  # XXX: should be taken from the site configuration
haveBibUtils = _hasCommands('bib2xml')
FIX_BIBTEX = os.environ.has_key('FIX_BIBTEX')


class BibtexParser(BibliographyParser):
    """
    A specific parser to process input in BiBTeX-format.
    """

    meta_type = "Bibtex Parser"

    format = {'name': 'BibTeX', 'extension': 'bib'}

    def __init__(self,
                 id='bibtex',
                 title="BibTeX parser",
Exemplo n.º 2
0
 def available(self):
     return bool(_hasCommands('latex|bibtex|pdflatex'))
Exemplo n.º 3
0
import os
import re

from zope.component import getUtility, ComponentLookupError

from bibliograph.parsing.parsers.base import BibliographyParser
from bibliograph.rendering.interfaces import IBibTransformUtility

from bibliograph.core.utils import _encode, _decode
from bibliograph.core.bibutils import _hasCommands
from bibliograph.core.encodings import _latex2utf8enc_mapping
from bibliograph.core.encodings import _latex2utf8enc_mapping_simple


_encoding = 'utf-8'   # XXX: should be taken from the site configuration
haveBibUtils = _hasCommands('bib2xml')
FIX_BIBTEX = os.environ.has_key('FIX_BIBTEX')

class BibtexParser(BibliographyParser):
    """
    A specific parser to process input in BiBTeX-format.
    """

    meta_type = "Bibtex Parser"

    format = {'name':'BibTeX',
              'extension':'bib'}

    def __init__(self,
                 id = 'bibtex',
                 title = "BibTeX parser",
Exemplo n.º 4
0
def test_suite():
    utilsavailable = True
    latexavailable = True

    suite = unittest.TestSuite()
    suite.addTest(
        doctestunit.DocFileSuite(
            'renderers/bibtex.txt',
            'renderers/utility.txt',
            package='bibliograph.rendering',
            setUp=setUp,
            tearDown=testing.tearDown,
            globs=dict(SimpleContent=SimpleContent),
            optionflags=OPTS,
            ))

    suite.addTest(doctestunit.DocTestSuite(
            module='bibliograph.rendering.utility',
            setUp=setUp,
            tearDown=testing.tearDown,
            optionflags=OPTS,
            ))

    if _hasCommands(commands.get('bib2end')):

        suite.addTest(doctestunit.DocFileSuite(
            'renderers/endnote.txt',
            package='bibliograph.rendering',
            setUp=setUp,
            tearDown=testing.tearDown,
            globs=dict(SimpleContent=SimpleContent),
            optionflags=OPTS,
            ))

    else:
        utilsavailable = False

    if _hasCommands(commands.get('bib2ris')):
        suite.addTest(doctestunit.DocFileSuite(
            'renderers/ris.txt',
            package='bibliograph.rendering',
            setUp=setUp,
            tearDown=testing.tearDown,
            globs=dict(SimpleContent=SimpleContent),
            optionflags=OPTS,
            ))
    else:
        utilsavailable = False

    if _hasCommands(commands.get('bib2xml')):
        suite.addTest(doctestunit.DocFileSuite(
            'renderers/xml.txt',
            package='bibliograph.rendering',
            setUp=setUp,
            tearDown=testing.tearDown,
            globs=dict(SimpleContent=SimpleContent),
            optionflags=OPTS,
            ))
    else:
        utilsavailable = False

    if _hasCommands('latex|bibtex|pdflatex'):
        suite.addTest(doctestunit.DocFileSuite(
            'renderers/pdf.txt',
            package='bibliograph.rendering',
            setUp=setUp,
            tearDown=testing.tearDown,
            globs=dict(SimpleContent=SimpleContent),
            optionflags=OPTS,
            ))
    else:
        latexavailable = False

    if utilsavailable:
        suite.addTest(doctestunit.DocFileSuite(
            'renderers/bibutility.txt',
            package='bibliograph.rendering',
            setUp=setUp,
            tearDown=testing.tearDown,
            globs=dict(SimpleContent=SimpleContent),
            optionflags=OPTS,
            ))

    if not utilsavailable:
        print NOBIBUTILSMSG
        print "-" * 20

    if not latexavailable:
        print NOLATEXMSG
        print "-" * 20

    return suite