# Path: rst2pdf/log.py
# def nodeid(node):


import codecs
    import pygments
        import locale
from docutils import nodes
from docutils.parsers.rst import directives
    from pygments.lexers import get_lexer_by_name
    from pygments.formatters.html import _get_ttype_class
from ..log import log
    from docutils.core import publish_cmdline, default_description
    from docutils.parsers.rst import directives
    def lex(self):
        # Get lexer for language (use text as fallback)
        try:
            if self.language and str(self.language).lower() != 'none':
                lexer = get_lexer_by_name(self.language.lower(), **self.custom_args)
            else:
                lexer = get_lexer_by_name('text', **self.custom_args)
        except ValueError:
            log.info("no pygments lexer for %s, using 'text'" % self.language)
            # what happens if pygment isn't present ?
            lexer = get_lexer_by_name('text')
        return pygments.lex(self.code, lexer)

    def join(self, tokens):
        """join subsequent tokens of same token-type"""
        tokens = iter(tokens)
        (lasttype, lastval) = next(tokens)
        for ttype, value in tokens:
            if ttype is lasttype:
                lastval += value
            else:
                yield (lasttype, lastval)
                (lasttype, lastval) = (ttype, value)
        yield (lasttype, lastval)

    def __iter__(self):
        """parse code string and yield "clasified" tokens"""
        try:
            tokens = self.lex()
        except IOError:

# Path: rst2pdf/log.py
# def nodeid(node):


# Path: rst2pdf/directives/code_block.py
import codecs
    import pygments
        import locale
from docutils import nodes
from docutils.parsers.rst import directives
    from pygments.lexers import get_lexer_by_name
    from pygments.formatters.html import _get_ttype_class
from ..log import log
    from docutils.core import publish_cmdline, default_description
    from docutils.parsers.rst import directives

    def lex(self):
        # Get lexer for language (use text as fallback)
        try:
            if self.language and str(self.language).lower() != 'none':
                lexer = get_lexer_by_name(self.language.lower(), **self.custom_args)
            else:
                lexer = get_lexer_by_name('text', **self.custom_args)
        except ValueError:
            log.info("no pygments lexer for %s, using 'text'" % self.language)
            # what happens if pygment isn't present ?
            lexer = get_lexer_by_name('text')
        return pygments.lex(self.code, lexer)

    def join(self, tokens):
        """join subsequent tokens of same token-type"""
        tokens = iter(tokens)
        (lasttype, lastval) = next(tokens)
        for ttype, value in tokens:
            if ttype is lasttype:
                lastval += value
            else:
                yield (lasttype, lastval)
                (lasttype, lastval) = (ttype, value)
        yield (lasttype, lastval)

    def __iter__(self):
        """parse code string and yield "clasified" tokens"""
        try:
            tokens = self.lex()
        except IOError:

            log.info("Pygments lexer not found, using fallback")