diff options
author | Éric Araujo <merwok@netwok.org> | 2011-09-18 21:12:30 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-09-18 21:12:30 (GMT) |
commit | c1b7e7f8bbcae936a5e75277e9e86d9ebec5469f (patch) | |
tree | 8f179ac3234e344d366bce980199e0c4be71ca25 /Lib | |
parent | f30b5ae6fd03b497a43d30489663a6baa9f2d800 (diff) | |
download | cpython-c1b7e7f8bbcae936a5e75277e9e86d9ebec5469f.zip cpython-c1b7e7f8bbcae936a5e75277e9e86d9ebec5469f.tar.gz cpython-c1b7e7f8bbcae936a5e75277e9e86d9ebec5469f.tar.bz2 |
A few style changes originally done in the distutils2 repo
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/packaging/command/build_scripts.py | 4 | ||||
-rw-r--r-- | Lib/packaging/create.py | 5 | ||||
-rw-r--r-- | Lib/shutil.py | 8 | ||||
-rw-r--r-- | Lib/test/test_sysconfig.py | 16 |
4 files changed, 16 insertions, 17 deletions
diff --git a/Lib/packaging/command/build_scripts.py b/Lib/packaging/command/build_scripts.py index fe14e0a..d651ae0 100644 --- a/Lib/packaging/command/build_scripts.py +++ b/Lib/packaging/command/build_scripts.py @@ -3,7 +3,7 @@ import os import re import sysconfig -import tokenize +from tokenize import detect_encoding from packaging.command.cmd import Command from packaging.util import convert_path, newer @@ -83,7 +83,7 @@ class build_scripts(Command, Mixin2to3): raise f = None else: - encoding, lines = tokenize.detect_encoding(f.readline) + encoding, lines = detect_encoding(f.readline) f.seek(0) first_line = f.readline() if not first_line: diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py index 1e84e2e..34a8c82 100644 --- a/Lib/packaging/create.py +++ b/Lib/packaging/create.py @@ -25,10 +25,11 @@ import sys import glob import shutil import sysconfig -import tokenize from hashlib import md5 from textwrap import dedent +from tokenize import detect_encoding from configparser import RawConfigParser + # importing this with an underscore as it should be replaced by the # dict form or another structures for all purposes from packaging._trove import all_classifiers as _CLASSIFIERS_LIST @@ -111,7 +112,7 @@ def load_setup(): been loaded before, because we are monkey patching its setup function with a particular one""" with open("setup.py", "rb") as f: - encoding, lines = tokenize.detect_encoding(f.readline) + encoding, lines = detect_encoding(f.readline) with open("setup.py", encoding=encoding) as f: imp.load_module("setup", f, "setup.py", (".py", "r", imp.PY_SOURCE)) diff --git a/Lib/shutil.py b/Lib/shutil.py index 0c096cb..2025ef8 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -391,7 +391,7 @@ def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, compress_ext['bzip2'] = '.bz2' # flags for compression program, each element of list will be an argument - if compress is not None and compress not in compress_ext.keys(): + if compress is not None and compress not in compress_ext: raise ValueError("bad value for 'compress', or compression format not " "supported : {0}".format(compress)) @@ -497,7 +497,7 @@ _ARCHIVE_FORMATS = { 'gztar': (_make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"), 'bztar': (_make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"), 'tar': (_make_tarball, [('compress', None)], "uncompressed tar file"), - 'zip': (_make_zipfile, [],"ZIP file") + 'zip': (_make_zipfile, [], "ZIP file") } if _BZ2_SUPPORTED: @@ -530,7 +530,7 @@ def register_archive_format(name, function, extra_args=None, description=''): if not isinstance(extra_args, (tuple, list)): raise TypeError('extra_args needs to be a sequence') for element in extra_args: - if not isinstance(element, (tuple, list)) or len(element) !=2 : + if not isinstance(element, (tuple, list)) or len(element) !=2: raise TypeError('extra_args elements are : (arg_name, value)') _ARCHIVE_FORMATS[name] = (function, extra_args, description) @@ -682,7 +682,7 @@ def _unpack_zipfile(filename, extract_dir): if not name.endswith('/'): # file data = zip.read(info.filename) - f = open(target,'wb') + f = open(target, 'wb') try: f.write(data) finally: diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 773d523..08b40a1 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -39,7 +39,7 @@ class TestSysConfig(unittest.TestCase): self._config_vars = copy(sysconfig._CONFIG_VARS) self._added_envvars = [] self._changed_envvars = [] - for var in ('MACOSX_DEPLOYMENT_TARGET', 'Path'): + for var in ('MACOSX_DEPLOYMENT_TARGET', 'PATH'): if var in os.environ: self._changed_envvars.append((var, os.environ[var])) else: @@ -87,21 +87,19 @@ class TestSysConfig(unittest.TestCase): scheme = get_paths() default_scheme = _get_default_scheme() wanted = _expand_vars(default_scheme, None) - wanted = list(wanted.items()) - wanted.sort() - scheme = list(scheme.items()) - scheme.sort() + wanted = sorted(wanted.items()) + scheme = sorted(scheme.items()) self.assertEqual(scheme, wanted) def test_get_path(self): - # xxx make real tests here + # XXX make real tests here for scheme in _SCHEMES: for name in _SCHEMES[scheme]: res = get_path(name, scheme) def test_get_config_vars(self): cvars = get_config_vars() - self.assertTrue(isinstance(cvars, dict)) + self.assertIsInstance(cvars, dict) self.assertTrue(cvars) def test_get_platform(self): @@ -236,8 +234,8 @@ class TestSysConfig(unittest.TestCase): # On Windows, the EXE needs to know where pythonXY.dll is at so we have # to add the directory to the path. if sys.platform == "win32": - os.environ["Path"] = "{};{}".format( - os.path.dirname(sys.executable), os.environ["Path"]) + os.environ["PATH"] = "{};{}".format( + os.path.dirname(sys.executable), os.environ["PATH"]) # Issue 7880 def get(python): |