ThirdParty/Pygments/pygments/lexer.py

branch
Py2 comp.
changeset 2669
11a6696ff868
parent 2525
8b507a9a2d40
child 3079
0233bbe9a9c4
--- a/ThirdParty/Pygments/pygments/lexer.py	Sun Apr 21 20:30:56 2013 +0200
+++ b/ThirdParty/Pygments/pygments/lexer.py	Thu May 23 19:58:41 2013 +0200
@@ -8,9 +8,8 @@
     :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
-from __future__ import unicode_literals    # __IGNORE_WARNING__
 try:
-    str = unicode
+    str = unicode   # __IGNORE_WARNING__
 except (NameError):
     pass
 
@@ -37,6 +36,14 @@
 _default_analyse = staticmethod(lambda x: 0.0)
 
 
+def with_metaclass(meta, base=object):
+    """
+    Python independent version to create a base class with a metaclass.
+    Taken from six 1.3.0 (http://pythonhosted.org/six)
+    """
+    return meta("NewBase", (base,), {})
+
+
 class LexerMeta(type):
     """
     This metaclass automagically converts ``analyse_text`` methods into
@@ -49,7 +56,7 @@
         return type.__new__(cls, name, bases, d)
 
 
-class Lexer(object, metaclass=LexerMeta):
+class Lexer(with_metaclass(LexerMeta, object)):
     """
     Lexer for a specific language.
 
@@ -538,7 +545,7 @@
         return type.__call__(cls, *args, **kwds)
 
 
-class RegexLexer(Lexer, metaclass=RegexLexerMeta):
+class RegexLexer(with_metaclass(RegexLexerMeta, Lexer)):
     """
     Base for simple stateful regular expression-based lexers.
     Simplifies the lexing process so that you need only

eric ide

mercurial