Thu, 23 May 2013 19:58:41 +0200
Fixes for pygments: version independent metaclass creation and library selection.
--- 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
--- a/ThirdParty/Pygments/pygments/lexers/_luabuiltins.py Sun Apr 21 20:30:56 2013 +0200 +++ b/ThirdParty/Pygments/pygments/lexers/_luabuiltins.py Thu May 23 19:58:41 2013 +0200 @@ -144,7 +144,11 @@ if __name__ == '__main__': import re - import urllib.request, urllib.parse, urllib.error + try: # Py3 + import urllib.request as request + except (ImportError): + import urllib2 as request # __IGNORE_WARNING__ + import pprint # you can't generally find out what module a function belongs to if you @@ -190,7 +194,7 @@ def get_newest_version(): - f = urllib.request.urlopen('http://www.lua.org/manual/') + f = request.urlopen('http://www.lua.org/manual/') r = re.compile(r'^<A HREF="(\d\.\d)/">Lua \1</A>') for line in f: m = r.match(line) @@ -198,7 +202,7 @@ return m.groups()[0] def get_lua_functions(version): - f = urllib.request.urlopen('http://www.lua.org/manual/%s/' % version) + f = request.urlopen('http://www.lua.org/manual/%s/' % version) r = re.compile(r'^<A HREF="manual.html#pdf-(.+)">\1</A>') functions = [] for line in f:
--- a/ThirdParty/Pygments/pygments/lexers/_phpbuiltins.py Sun Apr 21 20:30:56 2013 +0200 +++ b/ThirdParty/Pygments/pygments/lexers/_phpbuiltins.py Thu May 23 19:58:41 2013 +0200 @@ -3713,7 +3713,10 @@ import re import shutil import tarfile - import urllib.request, urllib.parse, urllib.error + try: # Py3 + import urllib.request as request + except (ImportError): + import urllib2 as request # __IGNORE_WARNING__ PHP_MANUAL_URL = 'http://us3.php.net/distributions/manual/php_manual_en.tar.gz' PHP_MANUAL_DIR = './php-chunked-xhtml/' @@ -3754,7 +3757,7 @@ return modules def get_php_references(): - download = urllib.request.urlretrieve(PHP_MANUAL_URL) + download = request.urlretrieve(PHP_MANUAL_URL) tar = tarfile.open(download[0]) tar.extractall() tar.close()
--- a/ThirdParty/Pygments/pygments/lexers/_postgres_builtins.py Sun Apr 21 20:30:56 2013 +0200 +++ b/ThirdParty/Pygments/pygments/lexers/_postgres_builtins.py Thu May 23 19:58:41 2013 +0200 @@ -10,9 +10,13 @@ """ from __future__ import unicode_literals # __IGNORE_WARNING__ +try: + str = unicode # __IGNORE_WARNING__ + import urllib2 as request +except (NameError): + import urllib.request as request # __IGNORE_WARNING__ import re -import urllib.request, urllib.parse, urllib.error # One man's constant is another man's variable. SOURCE_URL = 'https://github.com/postgres/postgres/raw/master' @@ -99,7 +103,7 @@ return dt def fetch(url): - return urllib.request.urlopen(url) + return request.urlopen(url) def update_consts(filename, constname, content): f = open(filename)
--- a/ThirdParty/Pygments/pygments/style.py Sun Apr 21 20:30:56 2013 +0200 +++ b/ThirdParty/Pygments/pygments/style.py Thu May 23 19:58:41 2013 +0200 @@ -13,6 +13,13 @@ from pygments.token import Token, STANDARD_TYPES +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 StyleMeta(type): @@ -106,7 +113,7 @@ return len(cls._styles) -class Style(object, metaclass=StyleMeta): +class Style(with_metaclass(StyleMeta, object)): background_color = '#ffffff' #: highlight background color
--- a/ThirdParty/Pygments/pygments/unistring.py Sun Apr 21 20:30:56 2013 +0200 +++ b/ThirdParty/Pygments/pygments/unistring.py Thu May 23 19:58:41 2013 +0200 @@ -12,6 +12,10 @@ :license: BSD, see LICENSE for details. """ from __future__ import unicode_literals # __IGNORE_WARNING__ +try: + chr = unichr +except (NameError): + pass from pygments.util import u_prefix
--- a/ThirdParty/Pygments/pygments/util.py Sun Apr 21 20:30:56 2013 +0200 +++ b/ThirdParty/Pygments/pygments/util.py Thu May 23 19:58:41 2013 +0200 @@ -10,6 +10,10 @@ """ from __future__ import unicode_literals # __IGNORE_WARNING__ +try: + chr = unichr +except (NameError): + pass import re import sys @@ -258,9 +262,9 @@ if sys.version_info < (3,0): b = bytes = str u_prefix = 'u' - import io, io - BytesIO = io.StringIO - StringIO = io.StringIO + import StringIO, cStringIO + BytesIO = cStringIO.StringIO + StringIO = StringIO.StringIO uni_open = codecs.open else: import builtins