Mercurial > moin > 1.9
changeset 6102:df21062e294d
keep python_compatibility as dummy
it was for old python / old stdlib.
keep the dummy just in case some own or extension code imports something from here.
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Tue, 06 Sep 2016 00:26:46 +0200 |
parents | 316986758258 |
children | 500f68d3e2fd |
files | MoinMoin/support/python_compatibility.py |
diffstat | 1 files changed, 11 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/support/python_compatibility.py Tue Sep 06 00:21:08 2016 +0200 +++ b/MoinMoin/support/python_compatibility.py Tue Sep 06 00:26:46 2016 +0200 @@ -1,67 +1,27 @@ """ MoinMoin - Support Package - Stuff for compatibility with older Python versions + Was: Stuff for compatibility with Python < 2.7. Just a dummy now. @copyright: 2007 Heinrich Wendel <heinrich.wendel@gmail.com>, 2009 MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ -min_req_exc = Exception("Minimum requirement for MoinMoin is Python 2.4.") +import string -try: - import string - rsplit = string.rsplit # Python >= 2.4 needed -except AttributeError: - raise min_req_exc - -try: - sorted = sorted # Python >= 2.4 needed -except NameError: - raise min_req_exc +rsplit = string.rsplit -try: - set = set # Python >= 2.4 needed - frozenset = frozenset -except NameError: - raise min_req_exc - +sorted = sorted -try: - from functools import partial # Python >= 2.5 needed -except (NameError, ImportError): - class partial(object): - def __init__(*args, **kw): - self = args[0] - self.fn, self.args, self.kw = (args[1], args[2:], kw) +set = set +frozenset = frozenset - def __call__(self, *args, **kw): - if kw and self.kw: - d = self.kw.copy() - d.update(kw) - else: - d = kw or self.kw - return self.fn(*(self.args + args), **d) +from functools import partial - -try: - import hashlib, hmac # Python >= 2.5 needed - hash_new = hashlib.new - def hmac_new(key, msg, digestmod=hashlib.sha1): - return hmac.new(key, msg, digestmod) +import hashlib, hmac -except (NameError, ImportError): - import sha - def hash_new(name, string=''): - if name in ('SHA1', 'sha1'): - return sha.new(string) - elif name in ('MD5', 'md5'): - import md5 - return md5.new(string) - raise ValueError("unsupported hash type") +hash_new = hashlib.new - def hmac_new(key, msg, digestmod=sha): - import hmac - return hmac.new(key, msg, digestmod) - +def hmac_new(key, msg, digestmod=hashlib.sha1): + return hmac.new(key, msg, digestmod)