home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __docformat__ = 'restructuredtext'
- __version__ = '$Id: errorhandler.py 1234 2008-05-22 20:26:12Z cthedot $'
- import os
- import re
- import sys
- import urllib
-
- class Deprecated(object):
-
- def __init__(self, msg):
- self.msg = msg
-
-
- def __call__(self, func):
-
- def newFunc(*args, **kwargs):
- import warnings
- warnings.warn('Call to deprecated method %r. %s' % (func.__name__, self.msg), category = DeprecationWarning, stacklevel = 2)
- return func(*args, **kwargs)
-
- newFunc.__name__ = func.__name__
- newFunc.__doc__ = func.__doc__
- newFunc.__dict__.update(func.__dict__)
- return newFunc
-
-
- _simpleescapes = re.compile(u'(\\\\[^0-9a-fA-F])').sub
-
- def normalize(x):
- if x:
-
- def removeescape(matchobj):
- return matchobj.group(0)[1:]
-
- x = _simpleescapes(removeescape, x)
- return x.lower()
- return x
-
-
- def path2url(path):
- return u'file:' + urllib.pathname2url(os.path.abspath(path))
-
-
- def pushtoken(token, tokens):
- yield token
- for t in tokens:
- yield t
-
-
-
- def string(value):
- value = value.replace(u'\n', u'\\a ').replace(u'\r', u'\\d ').replace(u'\x0c', u'\\c ').replace(u'"', u'\\"')
- if value.endswith(u'\\'):
- value = value[:-1] + u'\\\\'
-
- return u'"%s"' % value
-
-
- def stringvalue(string):
- return string.replace(u'\\' + string[0], string[0])[1:-1]
-
- _match_forbidden_in_uri = re.compile(u'.*?[\\(\\)\\s\\;,\'"]', re.U).match
-
- def uri(value):
- if _match_forbidden_in_uri(value):
- value = string(value)
-
- return u'url(%s)' % value
-
-
- def urivalue(uri):
- uri = uri[uri.find('(') + 1:-1].strip()
- if uri and uri[0] in '\'"' and uri[0] == uri[-1]:
- return stringvalue(uri)
- return uri
-
-