Commit f749ccab authored by stepshal's avatar stepshal

Add missing whitespace.

parent 45de6ea8
......@@ -20,7 +20,7 @@ class UnrecognizedFormat(DistutilsError):
"""Couldn't recognize the archive type"""
def default_filter(src,dst):
def default_filter(src, dst):
"""The default progress/filter callback; returns True for all files"""
return dst
......
......@@ -31,7 +31,7 @@ class Require:
def full_name(self):
"""Return full package/distribution name, w/version"""
if self.requested_version is not None:
return '%s-%s' % (self.name,self.requested_version)
return '%s-%s' % (self.name, self.requested_version)
return self.name
def version_ok(self, version):
......@@ -52,7 +52,7 @@ class Require:
if self.attribute is None:
try:
f,p,i = find_module(self.module,paths)
f, p, i = find_module(self.module, paths)
if f: f.close()
return default
except ImportError:
......@@ -83,7 +83,7 @@ def _iter_code(code):
from array import array
from dis import HAVE_ARGUMENT, EXTENDED_ARG
bytes = array('b',code.co_code)
bytes = array('b', code.co_code)
eof = len(code.co_code)
ptr = 0
......@@ -107,7 +107,7 @@ def _iter_code(code):
arg = None
ptr += 1
yield op,arg
yield op, arg
def find_module(module, paths=None):
......@@ -117,14 +117,14 @@ def find_module(module, paths=None):
while parts:
part = parts.pop(0)
f, path, (suffix,mode,kind) = info = imp.find_module(part, paths)
f, path, (suffix, mode, kind) = info = imp.find_module(part, paths)
if kind==PKG_DIRECTORY:
parts = parts or ['__init__']
paths = [path]
elif parts:
raise ImportError("Can't find %r in %s" % (parts,module))
raise ImportError("Can't find %r in %s" % (parts, module))
return info
......
This diff is collapsed.
This diff is collapsed.
......@@ -19,5 +19,5 @@ def strip_fragment(url):
url, fragment = splittag(url)
return url
if sys.version_info >= (2,7):
if sys.version_info >= (2, 7):
strip_fragment = lambda x: x
......@@ -238,7 +238,7 @@ def run_setup(setup_script, args):
sys.path.insert(0, setup_dir)
# reset to include setup dir, w/clean callback list
working_set.__init__()
working_set.callbacks.append(lambda dist:dist.activate())
working_set.callbacks.append(lambda dist: dist.activate())
def runner():
ns = dict(__file__=setup_script, __name__='__main__')
......@@ -258,12 +258,12 @@ class AbstractSandbox:
def __init__(self):
self._attrs = [
name for name in dir(_os)
if not name.startswith('_') and hasattr(self,name)
if not name.startswith('_') and hasattr(self, name)
]
def _copy(self, source):
for name in self._attrs:
setattr(os, name, getattr(source,name))
setattr(os, name, getattr(source, name))
def run(self, func):
"""Run 'func' under os sandboxing"""
......@@ -282,24 +282,24 @@ class AbstractSandbox:
self._copy(_os)
def _mk_dual_path_wrapper(name):
original = getattr(_os,name)
original = getattr(_os, name)
def wrap(self,src,dst,*args,**kw):
def wrap(self, src, dst, *args, **kw):
if self._active:
src,dst = self._remap_pair(name,src,dst,*args,**kw)
return original(src,dst,*args,**kw)
src, dst = self._remap_pair(name, src, dst, *args, **kw)
return original(src, dst, *args, **kw)
return wrap
for name in ["rename", "link", "symlink"]:
if hasattr(_os,name): locals()[name] = _mk_dual_path_wrapper(name)
if hasattr(_os, name): locals()[name] = _mk_dual_path_wrapper(name)
def _mk_single_path_wrapper(name, original=None):
original = original or getattr(_os,name)
original = original or getattr(_os, name)
def wrap(self,path,*args,**kw):
def wrap(self, path, *args, **kw):
if self._active:
path = self._remap_input(name,path,*args,**kw)
return original(path,*args,**kw)
path = self._remap_input(name, path, *args, **kw)
return original(path, *args, **kw)
return wrap
if _file:
......@@ -310,51 +310,51 @@ class AbstractSandbox:
"remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat",
"startfile", "mkfifo", "mknod", "pathconf", "access"
]:
if hasattr(_os,name): locals()[name] = _mk_single_path_wrapper(name)
if hasattr(_os, name): locals()[name] = _mk_single_path_wrapper(name)
def _mk_single_with_return(name):
original = getattr(_os,name)
original = getattr(_os, name)
def wrap(self,path,*args,**kw):
def wrap(self, path, *args, **kw):
if self._active:
path = self._remap_input(name,path,*args,**kw)
return self._remap_output(name, original(path,*args,**kw))
return original(path,*args,**kw)
path = self._remap_input(name, path, *args, **kw)
return self._remap_output(name, original(path, *args, **kw))
return original(path, *args, **kw)
return wrap
for name in ['readlink', 'tempnam']:
if hasattr(_os,name): locals()[name] = _mk_single_with_return(name)
if hasattr(_os, name): locals()[name] = _mk_single_with_return(name)
def _mk_query(name):
original = getattr(_os,name)
original = getattr(_os, name)
def wrap(self,*args,**kw):
retval = original(*args,**kw)
def wrap(self, *args, **kw):
retval = original(*args, **kw)
if self._active:
return self._remap_output(name, retval)
return retval
return wrap
for name in ['getcwd', 'tmpnam']:
if hasattr(_os,name): locals()[name] = _mk_query(name)
if hasattr(_os, name): locals()[name] = _mk_query(name)
def _validate_path(self,path):
def _validate_path(self, path):
"""Called to remap or validate any path, whether input or output"""
return path
def _remap_input(self,operation,path,*args,**kw):
def _remap_input(self, operation, path, *args, **kw):
"""Called for path inputs"""
return self._validate_path(path)
def _remap_output(self,operation,path):
def _remap_output(self, operation, path):
"""Called for path outputs"""
return self._validate_path(path)
def _remap_pair(self,operation,src,dst,*args,**kw):
def _remap_pair(self, operation, src, dst, *args, **kw):
"""Called for path pairs like rename, link, and symlink operations"""
return (
self._remap_input(operation+'-from',src,*args,**kw),
self._remap_input(operation+'-to',dst,*args,**kw)
self._remap_input(operation+'-from', src, *args, **kw),
self._remap_input(operation+'-to', dst, *args, **kw)
)
......@@ -388,7 +388,7 @@ class DirectorySandbox(AbstractSandbox):
def __init__(self, sandbox, exceptions=_EXCEPTIONS):
self._sandbox = os.path.normcase(os.path.realpath(sandbox))
self._prefix = os.path.join(self._sandbox,'')
self._prefix = os.path.join(self._sandbox, '')
self._exceptions = [
os.path.normcase(os.path.realpath(path))
for path in exceptions
......@@ -403,12 +403,12 @@ class DirectorySandbox(AbstractSandbox):
def _file(self, path, mode='r', *args, **kw):
if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path):
self._violation("file", path, mode, *args, **kw)
return _file(path,mode,*args,**kw)
return _file(path, mode, *args, **kw)
def _open(self, path, mode='r', *args, **kw):
if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path):
self._violation("open", path, mode, *args, **kw)
return _open(path,mode,*args,**kw)
return _open(path, mode, *args, **kw)
def tmpnam(self):
self._violation("tmpnam")
......@@ -448,13 +448,13 @@ class DirectorySandbox(AbstractSandbox):
"""Called for path pairs like rename, link, and symlink operations"""
if not self._ok(src) or not self._ok(dst):
self._violation(operation, src, dst, *args, **kw)
return (src,dst)
return (src, dst)
def open(self, file, flags, mode=0o777, *args, **kw):
"""Called for low-level os.open()"""
if flags & WRITE_FLAGS and not self._ok(file):
self._violation("os.open", file, flags, mode, *args, **kw)
return _os.open(file,flags,mode, *args, **kw)
return _os.open(file, flags, mode, *args, **kw)
WRITE_FLAGS = functools.reduce(
operator.or_, [getattr(_os, a, 0) for a in
......
......@@ -7,7 +7,7 @@ def __boot():
else:
PYTHONPATH = PYTHONPATH.split(os.pathsep)
pic = getattr(sys,'path_importer_cache',{})
pic = getattr(sys, 'path_importer_cache', {})
stdpath = sys.path[len(PYTHONPATH):]
mydir = os.path.dirname(__file__)
#print "searching",stdpath,sys.path
......@@ -25,14 +25,14 @@ def __boot():
else:
try:
import imp # Avoid import loop in Python >= 3.3
stream, path, descr = imp.find_module('site',[item])
stream, path, descr = imp.find_module('site', [item])
except ImportError:
continue
if stream is None:
continue
try:
# This should actually reload the current module
imp.load_module('site',stream,path,descr)
imp.load_module('site', stream, path, descr)
finally:
stream.close()
break
......@@ -41,9 +41,9 @@ def __boot():
#print "loaded", __file__
known_paths = dict([(makepath(item)[1],1) for item in sys.path]) # 2.2 comp
known_paths = dict([(makepath(item)[1], 1) for item in sys.path]) # 2.2 comp
oldpos = getattr(sys,'__egginsert',0) # save old insertion position
oldpos = getattr(sys, '__egginsert', 0) # save old insertion position
sys.__egginsert = 0 # and reset the current one
for item in PYTHONPATH:
......
......@@ -27,7 +27,7 @@ def makeSetup(**args):
distutils.core._setup_stop_after = "commandline"
# Don't let system command line leak into tests!
args.setdefault('script_args',['install'])
args.setdefault('script_args', ['install'])
try:
return setuptools.setup(**args)
......@@ -56,35 +56,35 @@ class TestDepends:
fc = six.get_function_code(f1)
# unrecognized name
assert dep.extract_constant(fc,'q', -1) is None
assert dep.extract_constant(fc, 'q', -1) is None
# constant assigned
dep.extract_constant(fc,'x', -1) == "test"
dep.extract_constant(fc, 'x', -1) == "test"
# expression assigned
dep.extract_constant(fc,'y', -1) == -1
dep.extract_constant(fc, 'y', -1) == -1
# recognized name, not assigned
dep.extract_constant(fc,'z', -1) is None
dep.extract_constant(fc, 'z', -1) is None
def testFindModule(self):
with pytest.raises(ImportError):
dep.find_module('no-such.-thing')
with pytest.raises(ImportError):
dep.find_module('setuptools.non-existent')
f,p,i = dep.find_module('setuptools.tests')
f, p, i = dep.find_module('setuptools.tests')
f.close()
@needs_bytecode
def testModuleExtract(self):
from email import __version__
assert dep.get_module_constant('email','__version__') == __version__
assert dep.get_module_constant('sys','version') == sys.version
assert dep.get_module_constant('setuptools.tests','__doc__') == __doc__
assert dep.get_module_constant('email', '__version__') == __version__
assert dep.get_module_constant('sys', 'version') == sys.version
assert dep.get_module_constant('setuptools.tests', '__doc__') == __doc__
@needs_bytecode
def testRequire(self):
req = Require('Email','1.0.3','email')
req = Require('Email', '1.0.3', 'email')
assert req.name == 'Email'
assert req.module == 'email'
......@@ -101,12 +101,12 @@ class TestDepends:
assert req.is_present()
assert req.is_current()
req = Require('Email 3000','03000','email',format=LooseVersion)
req = Require('Email 3000', '03000', 'email', format=LooseVersion)
assert req.is_present()
assert not req.is_current()
assert not req.version_ok('unknown')
req = Require('Do-what-I-mean','1.0','d-w-i-m')
req = Require('Do-what-I-mean', '1.0', 'd-w-i-m')
assert not req.is_present()
assert not req.is_current()
......@@ -125,22 +125,22 @@ class TestDepends:
class TestDistro:
def setup_method(self, method):
self.e1 = Extension('bar.ext',['bar.c'])
self.e1 = Extension('bar.ext', ['bar.c'])
self.e2 = Extension('c.y', ['y.c'])
self.dist = makeSetup(
packages=['a', 'a.b', 'a.b.c', 'b', 'c'],
py_modules=['b.d','x'],
py_modules=['b.d', 'x'],
ext_modules = (self.e1, self.e2),
package_dir = {},
)
def testDistroType(self):
assert isinstance(self.dist,setuptools.dist.Distribution)
assert isinstance(self.dist, setuptools.dist.Distribution)
def testExcludePackage(self):
self.dist.exclude_package('a')
assert self.dist.packages == ['b','c']
assert self.dist.packages == ['b', 'c']
self.dist.exclude_package('b')
assert self.dist.packages == ['c']
......@@ -169,7 +169,7 @@ class TestDistro:
assert self.dist.ext_modules == [self.e2, self.e1]
def testExcludePackages(self):
self.dist.exclude(packages=['c','b','a'])
self.dist.exclude(packages=['c', 'b', 'a'])
assert self.dist.packages == []
assert self.dist.py_modules == ['x']
assert self.dist.ext_modules == [self.e1]
......@@ -199,13 +199,13 @@ class TestDistro:
with pytest.raises(DistutilsSetupError):
self.dist.exclude(nonexistent_option='x')
with pytest.raises(DistutilsSetupError):
self.dist.include(packages={'x':'y'})
self.dist.include(packages={'x': 'y'})
with pytest.raises(DistutilsSetupError):
self.dist.exclude(packages={'x':'y'})
self.dist.exclude(packages={'x': 'y'})
with pytest.raises(DistutilsSetupError):
self.dist.include(ext_modules={'x':'y'})
self.dist.include(ext_modules={'x': 'y'})
with pytest.raises(DistutilsSetupError):
self.dist.exclude(ext_modules={'x':'y'})
self.dist.exclude(ext_modules={'x': 'y'})
with pytest.raises(DistutilsSetupError):
self.dist.include(package_dir=['q'])
......@@ -216,31 +216,31 @@ class TestDistro:
class TestFeatures:
def setup_method(self, method):
self.req = Require('Distutils','1.0.3','distutils')
self.req = Require('Distutils', '1.0.3', 'distutils')
self.dist = makeSetup(
features={
'foo': Feature("foo",standard=True,require_features=['baz',self.req]),
'foo': Feature("foo", standard=True, require_features=['baz', self.req]),
'bar': Feature("bar", standard=True, packages=['pkg.bar'],
py_modules=['bar_et'], remove=['bar.ext'],
),
'baz': Feature(
"baz", optional=False, packages=['pkg.baz'],
scripts = ['scripts/baz_it'],
libraries=[('libfoo','foo/foofoo.c')]
libraries=[('libfoo', 'foo/foofoo.c')]
),
'dwim': Feature("DWIM", available=False, remove='bazish'),
},
script_args=['--without-bar', 'install'],
packages = ['pkg.bar', 'pkg.foo'],
py_modules = ['bar_et', 'bazish'],
ext_modules = [Extension('bar.ext',['bar.c'])]
ext_modules = [Extension('bar.ext', ['bar.c'])]
)
def testDefaults(self):
assert not Feature(
"test",standard=True,remove='x',available=False
"test", standard=True, remove='x', available=False
).include_by_default()
assert Feature("test",standard=True,remove='x').include_by_default()
assert Feature("test", standard=True, remove='x').include_by_default()
# Feature must have either kwargs, removes, or require_features
with pytest.raises(DistutilsSetupError):
Feature("test")
......@@ -252,16 +252,16 @@ class TestFeatures:
def testFeatureOptions(self):
dist = self.dist
assert (
('with-dwim',None,'include DWIM') in dist.feature_options
('with-dwim', None, 'include DWIM') in dist.feature_options
)
assert (
('without-dwim',None,'exclude DWIM (default)') in dist.feature_options
('without-dwim', None, 'exclude DWIM (default)') in dist.feature_options
)
assert (
('with-bar',None,'include bar (default)') in dist.feature_options
('with-bar', None, 'include bar (default)') in dist.feature_options
)
assert (
('without-bar',None,'exclude bar') in dist.feature_options
('without-bar', None, 'exclude bar') in dist.feature_options
)
assert dist.feature_negopt['without-foo'] == 'with-foo'
assert dist.feature_negopt['without-bar'] == 'with-bar'
......@@ -277,7 +277,7 @@ class TestFeatures:
assert (not 'pkg.bar' in dist.packages)
assert ('pkg.baz' in dist.packages)
assert ('scripts/baz_it' in dist.scripts)
assert (('libfoo','foo/foofoo.c') in dist.libraries)
assert (('libfoo', 'foo/foofoo.c') in dist.libraries)
assert dist.ext_modules == []
assert dist.require_features == [self.req]
......@@ -288,7 +288,7 @@ class TestFeatures:
def testFeatureWithInvalidRemove(self):
with pytest.raises(SystemExit):
makeSetup(features={'x':Feature('x', remove='y')})
makeSetup(features={'x': Feature('x', remove='y')})
class TestCommandTests:
......@@ -298,7 +298,7 @@ class TestCommandTests:
assert (isinstance(test_cmd, distutils.cmd.Command))
def testLongOptSuiteWNoDefault(self):
ts1 = makeSetup(script_args=['test','--test-suite=foo.tests.suite'])
ts1 = makeSetup(script_args=['test', '--test-suite=foo.tests.suite'])
ts1 = ts1.get_command_obj('test')
ts1.ensure_finalized()
assert ts1.test_suite == 'foo.tests.suite'
......@@ -311,7 +311,7 @@ class TestCommandTests:
def testDefaultWModuleOnCmdLine(self):
ts3 = makeSetup(
test_suite='bar.tests',
script_args=['test','-m','foo.tests']
script_args=['test', '-m', 'foo.tests']
).get_command_obj('test')
ts3.ensure_finalized()
assert ts3.test_module == 'foo.tests'
......@@ -319,7 +319,7 @@ class TestCommandTests:
def testConflictingOptions(self):
ts4 = makeSetup(
script_args=['test','-m','bar.tests', '-s','foo.tests.suite']
script_args=['test', '-m', 'bar.tests', '-s', 'foo.tests.suite']
).get_command_obj('test')
with pytest.raises(DistutilsOptionError):
ts4.ensure_finalized()
......
......@@ -10,7 +10,7 @@ import pkg_resources
@contextlib.contextmanager
def tempdir(cd=lambda dir:None, **kwargs):
def tempdir(cd=lambda dir: None, **kwargs):
temp_dir = tempfile.mkdtemp(**kwargs)
orig_dir = os.getcwd()
try:
......
......@@ -32,7 +32,7 @@ def can_symlink():
def has_symlink():
bad_symlink = (
# Windows symlink directory detection is broken on Python 3.2
platform.system() == 'Windows' and sys.version_info[:2] == (3,2)
platform.system() == 'Windows' and sys.version_info[:2] == (3, 2)
)
return can_symlink() and not bad_symlink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment