diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2017-02-17 11:25:10 -0500 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2017-02-17 11:25:10 -0500 |
commit | d1b5b16fc0b96041e9c97df6707a062e2f64f88a (patch) | |
tree | b2cb29f2328f8329b8aa190c047f621b1051c746 | |
parent | 5b529f14d35c657c6d67a8fc5ee5dfaf89d5c6e3 (diff) | |
download | passlib-d1b5b16fc0b96041e9c97df6707a062e2f64f88a.tar.gz |
compat cleanup: removed print_() compat helper now that py25 support dropped.
-rw-r--r-- | admin/benchmarks.py | 9 | ||||
-rw-r--r-- | passlib/handlers/scram.py | 3 | ||||
-rw-r--r-- | passlib/tests/tox_support.py | 6 | ||||
-rw-r--r-- | passlib/utils/compat/__init__.py | 45 |
4 files changed, 9 insertions, 54 deletions
diff --git a/admin/benchmarks.py b/admin/benchmarks.py index b6a5d99..77212a4 100644 --- a/admin/benchmarks.py +++ b/admin/benchmarks.py @@ -6,6 +6,7 @@ parsing was being sped up. it could definitely be improved. #============================================================================= # init script env #============================================================================= +from __future__ import absolute_import, division, print_function import re import os, sys root = os.path.join(os.path.dirname(__file__), os.path.pardir) @@ -24,7 +25,7 @@ try: except ImportError: PasslibConfigWarning = None import passlib.utils.handlers as uh -from passlib.utils.compat import print_, unicode +from passlib.utils.compat import unicode from passlib.tests.utils import time_call # local @@ -78,10 +79,10 @@ class benchmark: usec = int(secs * 1e6) if usec < 1000: return "%.*g usec" % (precision, usec) - msec = usec / 1000 + msec = usec // 1000 if msec < 1000: return "%.*g msec" % (precision, msec) - sec = msec / 1000 + sec = msec // 1000 return "%.*g sec" % (precision, sec) #============================================================================= @@ -293,7 +294,7 @@ def main(*args): if any(re.match(arg, k) for arg in args)) helper = benchmark.run(source, maxtime=2, bestof=3) for name, secs, precision in helper: - print_("%-50s %9s (%d)" % (name, benchmark.pptime(secs), precision)) + print("%-50s %9s (%d)" % (name, benchmark.pptime(secs), precision)) if __name__ == "__main__": import sys diff --git a/passlib/handlers/scram.py b/passlib/handlers/scram.py index 57bf101..8122f2b 100644 --- a/passlib/handlers/scram.py +++ b/passlib/handlers/scram.py @@ -429,7 +429,6 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler): ##def _test_reference_scram(): ## "quick hack testing scram reference vectors" ## # NOTE: "n,," is GS2 header - see https://tools.ietf.org/html/rfc5801 -## from passlib.utils.compat import print_ ## ## engine = _scram_engine( ## alg="sha-1", @@ -437,7 +436,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler): ## rounds=4096, ## password=u"pencil", ## ) -## print_(engine.digest.encode("base64").rstrip()) +## print(engine.digest.encode("base64").rstrip()) ## ## msg = engine.format_auth_msg( ## username="user", diff --git a/passlib/tests/tox_support.py b/passlib/tests/tox_support.py index 43170bc..2ad42e4 100644 --- a/passlib/tests/tox_support.py +++ b/passlib/tests/tox_support.py @@ -2,6 +2,7 @@ #============================================================================= # init script env #============================================================================= +from __future__ import absolute_import, division, print_function import os, sys root_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) sys.path.insert(0, root_dir) @@ -14,7 +15,6 @@ import re import logging; log = logging.getLogger(__name__) # site # pkg -from passlib.utils.compat import print_ # local __all__ = [ ] @@ -40,7 +40,7 @@ def do_hash_tests(*args): from passlib.tests import test_handlers names = [TH_PATH + ":" + name + suffix for name in dir(test_handlers) if not name.startswith("_") and any(re.match(arg,name) for arg in args)] - print_("\n".join(names)) + print("\n".join(names)) return not names def do_preset_tests(name): @@ -48,7 +48,7 @@ def do_preset_tests(name): if name == "django" or name == "django-hashes": do_hash_tests("django_.*_test", "hex_md5_test") if name == "django": - print_("passlib.tests.test_ext_django") + print("passlib.tests.test_ext_django") else: raise ValueError("unknown name: %r" % name) diff --git a/passlib/utils/compat/__init__.py b/passlib/utils/compat/__init__.py index 4dba91f..21415c4 100644 --- a/passlib/utils/compat/__init__.py +++ b/passlib/utils/compat/__init__.py @@ -51,7 +51,6 @@ __all__ = [ # io 'BytesIO', 'StringIO', 'NativeStringIO', 'SafeConfigParser', - 'print_', # type detection ## 'is_mapping', @@ -309,8 +308,6 @@ if PY3: SafeConfigParser="configparser.ConfigParser", ) - print_ = getattr(builtins, "print") - else: _lazy_attrs = dict( BytesIO="cStringIO.StringIO", @@ -319,48 +316,6 @@ else: SafeConfigParser="ConfigParser.SafeConfigParser", ) - def print_(*args, **kwds): - """The new-style print function.""" - # extract kwd args - fp = kwds.pop("file", sys.stdout) - sep = kwds.pop("sep", None) - end = kwds.pop("end", None) - if kwds: - raise TypeError("invalid keyword arguments") - - # short-circuit if no target - if fp is None: - return - - # use unicode or bytes ? - want_unicode = isinstance(sep, unicode) or isinstance(end, unicode) or \ - any(isinstance(arg, unicode) for arg in args) - - # pick default end sequence - if end is None: - end = u"\n" if want_unicode else "\n" - elif not isinstance(end, unicode_or_bytes_types): - raise TypeError("end must be None or a string") - - # pick default separator - if sep is None: - sep = u" " if want_unicode else " " - elif not isinstance(sep, unicode_or_bytes_types): - raise TypeError("sep must be None or a string") - - # write to buffer - first = True - write = fp.write - for arg in args: - if first: - first = False - else: - write(sep) - if not isinstance(arg, basestring): - arg = str(arg) - write(arg) - write(end) - #============================================================================= # collections #============================================================================= |