def __init__(self, **options):
        self.python3 = get_bool_opt(options, 'python3', False)
        if self.python3:
            self.aliases = ['ipy3']
        else:
            self.aliases = ['ipy2', 'ipy']

        Lexer.__init__(self, **options)

        self.IPythonLexer = IPythonLexer(**options)
        self.IPythonConsoleLexer = IPythonConsoleLexer(**options)
    def __init__(self, **options):
        self.python3 = get_bool_opt(options, 'python3', False)
        if self.python3:
            self.aliases = ['ipy3']
        else:
            self.aliases = ['ipy2', 'ipy']

        Lexer.__init__(self, **options)

        self.IPythonLexer = IPythonLexer(**options)
        self.IPythonConsoleLexer = IPythonConsoleLexer(**options)
Пример #3
0
    def __init__(self, **options):
        self.python3 = get_bool_opt(options, "python3", False)
        if self.python3:
            self.aliases = ["ipy3"]
        else:
            self.aliases = ["ipy2", "ipy"]

        Lexer.__init__(self, **options)

        self.IPythonLexer = IPythonLexer(**options)
        self.IPythonConsoleLexer = IPythonConsoleLexer(**options)
Пример #4
0
 def __init__(self, **options):
     Lexer.__init__(self, **options)
     self.keywords = set()
     if get_bool_opt(options, 'turbopascal', True):
         self.keywords.update(self.TURBO_PASCAL_KEYWORDS)
     if get_bool_opt(options, 'delphi', True):
         self.keywords.update(self.DELPHI_KEYWORDS)
     if get_bool_opt(options, 'freepascal', True):
         self.keywords.update(self.FREE_PASCAL_KEYWORDS)
     self.builtins = set()
     for unit in get_list_opt(options, 'units', list(self.BUILTIN_UNITS)):
         self.builtins.update(self.BUILTIN_UNITS[unit])
 def __init__(self, **options):
     Lexer.__init__(self, **options)
     self.keywords = set()
     if get_bool_opt(options, 'turbopascal', True):
         self.keywords.update(self.TURBO_PASCAL_KEYWORDS)
     if get_bool_opt(options, 'delphi', True):
         self.keywords.update(self.DELPHI_KEYWORDS)
     if get_bool_opt(options, 'freepascal', True):
         self.keywords.update(self.FREE_PASCAL_KEYWORDS)
     self.builtins = set()
     for unit in get_list_opt(options, 'units', list(self.BUILTIN_UNITS)):
         self.builtins.update(self.BUILTIN_UNITS[unit])
Пример #6
0
def print_lexer(
    body: str, lexer: Lexer, label: str = None, prefix: str = None, indent: int = None
):
    if COLORIZE:
        prefix_str = prefix + " " if prefix else ""
        if prefix_str or indent:
            prefix_body = prefix_str + " " * (indent or 0)
            lexer.add_filter(PrefixFilter(prefix=prefix_body))
        tokens = list(pygments.lex(body, lexer=lexer))
        if label:
            fmt_label = [("fg:ansimagenta", label)]
            if prefix_str:
                fmt_label.insert(0, ("", prefix_str))
            print_formatted(FormattedText(fmt_label))
        print_formatted(PygmentsTokens(tokens))
    else:
        print_ext(body, label=label, prefix=prefix)
Пример #7
0
 def __init__(self, **options):
     self.python3 = get_bool_opt(options, 'python3', False)
     Lexer.__init__(self, **options)
Пример #8
0
 def __init__(self, left, right, lang, **options):
     self.left = left
     self.right = right
     self.lang = lang
     Lexer.__init__(self, **options)
Пример #9
0
 def __init__(self, max_len=50000, *args, **kwargs):
     self.max_len = max_len
     Lexer.__init__(self, *args, **kwargs)
    def __init__(self, **options):
        """Initialize the IPython console lexer.

        Parameters
        ----------
        python3 : bool
            If `True`, then the console inputs are parsed using a Python 3
            lexer. Otherwise, they are parsed using a Python 2 lexer.
        in1_regex : RegexObject
            The compiled regular expression used to detect the start
            of inputs. Although the IPython configuration setting may have a
            trailing whitespace, do not include it in the regex. If `None`,
            then the default input prompt is assumed.
        in2_regex : RegexObject
            The compiled regular expression used to detect the continuation
            of inputs. Although the IPython configuration setting may have a
            trailing whitespace, do not include it in the regex. If `None`,
            then the default input prompt is assumed.
        out_regex : RegexObject
            The compiled regular expression used to detect outputs. If `None`,
            then the default output prompt is assumed.

        """
        self.python3 = get_bool_opt(options, 'python3', False)
        if self.python3:
            self.aliases = ['ipython3console']
        else:
            self.aliases = ['ipython2console', 'ipythonconsole']

        in1_regex = options.get('in1_regex', self.in1_regex)
        in2_regex = options.get('in2_regex', self.in2_regex)
        out_regex = options.get('out_regex', self.out_regex)

        # So that we can work with input and output prompts which have been
        # rstrip'd (possibly by editors) we also need rstrip'd variants. If
        # we do not do this, then such prompts will be tagged as 'output'.
        # The reason can't just use the rstrip'd variants instead is because
        # we want any whitespace associated with the prompt to be inserted
        # with the token. This allows formatted code to be modified so as hide
        # the appearance of prompts, with the whitespace included. One example
        # use of this is in copybutton.js from the standard lib Python docs.
        in1_regex_rstrip = in1_regex.rstrip() + '\n'
        in2_regex_rstrip = in2_regex.rstrip() + '\n'
        out_regex_rstrip = out_regex.rstrip() + '\n'

        # Compile and save them all.
        attrs = [
            'in1_regex', 'in2_regex', 'out_regex', 'in1_regex_rstrip',
            'in2_regex_rstrip', 'out_regex_rstrip'
        ]
        for attr in attrs:
            self.__setattr__(attr, re.compile(locals()[attr]))

        Lexer.__init__(self, **options)

        if self.python3:
            pylexer = IPython3Lexer
            tblexer = IPythonTracebackLexer
        else:
            pylexer = IPythonLexer
            tblexer = IPythonTracebackLexer

        self.pylexer = pylexer(**options)
        self.tblexer = tblexer(**options)

        self.reset()
Пример #11
0
 def __init__(self, **options):
     self.python3 = get_bool_opt(options, 'python3', True)
     Lexer.__init__(self, **options)
Пример #12
0
 def __init__(self, **options):
     options['startinline'] = True
     Lexer.__init__(self, **options)
Пример #13
0
 def __init__(self):
     Lexer.__init__(self, tabsize=2, encoding='UTF-8')
Пример #14
0
 def __init__(self, *args, **kwargs):
     Lexer.__init__(self, *args, **kwargs)
     self.cur = []
Пример #15
0
 def __init__(self):
     Lexer.__init__(self, tabsize=2, encoding='UTF-8')
Пример #16
0
 def __init__(self, **options):
     from pygments.lexers.agile import RubyLexer
     self.ruby_lexer = RubyLexer(**options)
     Lexer.__init__(self, **options)
Пример #17
0
 def __init__(self, **options):
     Lexer.__init__(self, **options)
Пример #18
0
 def __init__(self, **options):
     options['tabsize'] = 2
     options['encoding'] = 'UTF-8'
     Lexer.__init__(self, **options)
Пример #19
0
 def __init__(self, **options):
     self.compress = get_choice_opt(options, "compress", ["", "none", "gz", "bz2"], "")
     Lexer.__init__(self, **options)
Пример #20
0
 def __init__(self, **options):
     self.compress = get_choice_opt(options, 'compress',
                                    ['', 'none', 'gz', 'bz2'], '')
     Lexer.__init__(self, **options)
    def __init__(self, **options):
        """Initialize the IPython console lexer.

        Parameters
        ----------
        python3 : bool
            If `True`, then the console inputs are parsed using a Python 3
            lexer. Otherwise, they are parsed using a Python 2 lexer.
        in1_regex : RegexObject
            The compiled regular expression used to detect the start
            of inputs. Although the IPython configuration setting may have a
            trailing whitespace, do not include it in the regex. If `None`,
            then the default input prompt is assumed.
        in2_regex : RegexObject
            The compiled regular expression used to detect the continuation
            of inputs. Although the IPython configuration setting may have a
            trailing whitespace, do not include it in the regex. If `None`,
            then the default input prompt is assumed.
        out_regex : RegexObject
            The compiled regular expression used to detect outputs. If `None`,
            then the default output prompt is assumed.

        """
        self.python3 = get_bool_opt(options, 'python3', False)
        if self.python3:
            self.aliases = ['ipython3console']
        else:
            self.aliases = ['ipython2console', 'ipythonconsole']

        in1_regex = options.get('in1_regex', self.in1_regex)
        in2_regex = options.get('in2_regex', self.in2_regex)
        out_regex = options.get('out_regex', self.out_regex)

        # So that we can work with input and output prompts which have been
        # rstrip'd (possibly by editors) we also need rstrip'd variants. If
        # we do not do this, then such prompts will be tagged as 'output'.
        # The reason can't just use the rstrip'd variants instead is because
        # we want any whitespace associated with the prompt to be inserted
        # with the token. This allows formatted code to be modified so as hide
        # the appearance of prompts, with the whitespace included. One example
        # use of this is in copybutton.js from the standard lib Python docs.
        in1_regex_rstrip = in1_regex.rstrip() + '\n'
        in2_regex_rstrip = in2_regex.rstrip() + '\n'
        out_regex_rstrip = out_regex.rstrip() + '\n'

        # Compile and save them all.
        attrs = ['in1_regex', 'in2_regex', 'out_regex',
                 'in1_regex_rstrip', 'in2_regex_rstrip', 'out_regex_rstrip']
        for attr in attrs:
            self.__setattr__(attr, re.compile(locals()[attr]))

        Lexer.__init__(self, **options)

        if self.python3:
            pylexer = IPython3Lexer
            tblexer = IPythonTracebackLexer
        else:
            pylexer = IPythonLexer
            tblexer = IPythonTracebackLexer

        self.pylexer = pylexer(**options)
        self.tblexer = tblexer(**options)

        self.reset()
Пример #22
0
 def __init__(self, **options):
     options['tabsize'] = 2
     options['encoding'] = 'UTF-8'
     Lexer.__init__(self, **options)
Пример #23
0
 def __init__(self, baselexer, **options):
     self.baselexer = baselexer
     Lexer.__init__(self, **options)
Пример #24
0
 def __init__(self, **options):
     self.compress = get_choice_opt(options, 'compress',
                                    ['', 'none', 'gz', 'bz2'], '')
     Lexer.__init__(self, **options)
Пример #25
0
 def __init__(self, **options):
     self.options = options
     Lexer.__init__(self, **options)
Пример #26
0
 def __init__(self, baselexer, **options):
     self.baselexer = baselexer
     Lexer.__init__(self, **options)
Пример #27
0
 def __init__(self, left, right, lang, **options):
     self.left = left
     self.right = right
     self.lang = lang
     Lexer.__init__(self, **options)
Пример #28
0
 def __init__(self, **options):
     from pygments.lexers.agile import RubyLexer
     self.ruby_lexer = RubyLexer(**options)
     Lexer.__init__(self, **options)
Пример #29
0
 def __init__(self, **options):
     self.options = options
     Lexer.__init__(self, **options)