Mercurial > genshi > genshi-test
diff genshi/util.py @ 914:c5faa881d87f experimental-py3k
py3k branch: add compatibility functions for dealing with python 3; factor existing compatibility functions out from genshi utils.
author | hodgestar |
---|---|
date | Sun, 24 Oct 2010 21:38:19 +0000 |
parents | fbe34d12acde |
children |
line wrap: on
line diff
--- a/genshi/util.py +++ b/genshi/util.py @@ -16,6 +16,8 @@ import htmlentitydefs as entities import re +from compat import any, all, stringrepr + __docformat__ = 'restructuredtext en' @@ -246,29 +248,3 @@ """ return _STRIPTAGS_RE.sub('', text) - -def stringrepr(string): - ascii = string.encode('ascii', 'backslashreplace') - quoted = "'" + ascii.replace("'", "\\'") + "'" - if len(ascii) > len(string): - return 'u' + quoted - return quoted - - -# Compatibility fallback implementations for older Python versions - -try: - all = all - any = any -except NameError: - def any(S): - for x in S: - if x: - return True - return False - - def all(S): - for x in S: - if not x: - return False - return True