diff options
Diffstat (limited to 'pygments/util.py')
-rw-r--r-- | pygments/util.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pygments/util.py b/pygments/util.py index 9f683c0e..b5e5d0b6 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -55,7 +55,7 @@ def get_bool_opt(options, optname, default=None): elif not isinstance(string, string_types): raise OptionError('Invalid type %r for option %s; use ' '1/0, yes/no, true/false, on/off' % ( - string, optname)) + string, optname)) elif string.lower() in ('1', 'yes', 'true', 'on'): return True elif string.lower() in ('0', 'no', 'false', 'off'): @@ -63,7 +63,7 @@ def get_bool_opt(options, optname, default=None): else: raise OptionError('Invalid value %r for option %s; use ' '1/0, yes/no, true/false, on/off' % ( - string, optname)) + string, optname)) def get_int_opt(options, optname, default=None): @@ -73,11 +73,11 @@ def get_int_opt(options, optname, default=None): except TypeError: raise OptionError('Invalid type %r for option %s; you ' 'must give an integer value' % ( - string, optname)) + string, optname)) except ValueError: raise OptionError('Invalid value %r for option %s; you ' 'must give an integer value' % ( - string, optname)) + string, optname)) def get_list_opt(options, optname, default=None): @@ -89,7 +89,7 @@ def get_list_opt(options, optname, default=None): else: raise OptionError('Invalid type %r for option %s; you ' 'must give a list value' % ( - val, optname)) + val, optname)) def docstring_headline(obj): @@ -185,6 +185,8 @@ def html_doctype_matches(text): _looks_like_xml_cache = {} + + def looks_like_xml(text): """Check if a doctype exists or if we have some tags.""" if xml_decl_re.match(text): @@ -200,6 +202,7 @@ def looks_like_xml(text): _looks_like_xml_cache[key] = rv return rv + # Python narrow build compatibility def _surrogatepair(c): @@ -210,6 +213,7 @@ def _surrogatepair(c): # http://www.unicode.org/book/ch03.pdf return (0xd7c0 + (c >> 10), (0xdc00 + (c & 0x3ff))) + def unirange(a, b): """Returns a regular expression string to match the given non-BMP range.""" if b < a: @@ -350,7 +354,8 @@ if sys.version_info < (3, 0): u_prefix = 'u' iteritems = dict.iteritems itervalues = dict.itervalues - import StringIO, cStringIO + import StringIO + import cStringIO # unfortunately, io.StringIO in Python 2 doesn't accept str at all StringIO = StringIO.StringIO BytesIO = cStringIO.StringIO |