Some fixes recommended by PyCharm

This commit is contained in:
Todd Gamblin 2013-12-25 15:40:32 -08:00
parent 4ff8766a22
commit 0cd5866eea
14 changed files with 28 additions and 25 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
/var/
*~
.DS_Store
.idea

View file

@ -58,7 +58,7 @@ def sys_type():
if sys_type: break
# Couldn't determine the sys_type for this machine.
if sys_type == None:
if sys_type is None:
raise NoSysTypeError()
if not isinstance(sys_type, basestring):

View file

@ -134,7 +134,7 @@ def cwrite(string, stream=sys.stdout, color=None):
then it will always write colored output. If not supplied,
then it will be set based on stream.isatty().
"""
if color == None:
if color is None:
color = stream.isatty()
stream.write(colorize(string, color=color))

View file

@ -4,7 +4,7 @@
def get_env_var(name, required=True):
value = os.environ.get(name)
if required and value == None:
if required and value is None:
print "%s must be run from spack." % os.path.abspath(sys.argv[0])
sys.exit(1)
return value
@ -49,7 +49,7 @@ def linker_args():
yield arg
elif arg == '-Xlinker':
target = get_next(arg, args)
if target != None:
if target is not None:
yield target
else:
other_args.append(arg)
@ -65,14 +65,14 @@ def linker_args():
for arg in largs:
if arg == '-rpath':
target = get_next(arg, largs)
if target != None:
if target is not None:
rpaths.append(target)
elif arg.startswith('-R'):
target = arg.replace('-R', '', 1)
if not target:
target = get_next(arg, largs)
if target == None: break
if target is None: break
if os.path.isdir(target):
rpaths.append(target)

View file

@ -151,11 +151,12 @@ def make_path_for_spec(self, spec):
spec_hash = self.hash_spec(spec)
installed_hash = self.hash_spec(installed_spec)
if installed_spec == spec_hash:
raise SpecHashCollisionError(installed_hash, spec_hash)
raise SpecHashCollisionError(
installed_hash, spec_hash, self.prefix_size)
else:
raise InconsistentInstallDirectoryError(
'Spec file in %s does not match SHA-1 hash!'
% (installed_spec, spec_file_path))
% spec_file_path)
mkdirp(path)
self.write_spec(spec, spec_file_path)

View file

@ -53,7 +53,7 @@ class SpecMultiMethod(object):
To register a method, you can do something like this:
mf = SpecMultiMethod()
mf.regsiter("^chaos_5_x86_64_ib", some_method)
mf.register("^chaos_5_x86_64_ib", some_method)
The object registered needs to be a Spec or some string that
will parse to be a valid spec.

View file

@ -221,7 +221,7 @@ def exists(pkg_name):
def packages_module():
# TODO: replace this with a proper package DB class, instead of this hackiness.
packages_path = re.sub(spack.module_path + '\/+', 'spack.', spack.packages_path)
packages_module = re.sub(r'\/', '.', packages_path)
packages_module = re.sub(r'/', '.', packages_path)
return packages_module

View file

@ -74,7 +74,8 @@ def test_conflicting_spec_constraints(self):
try:
mpileaks.package.validate_dependencies()
except spack.package.InvalidPackageDependencyError, e:
self.fail("validate_dependencies raised an exception: %s", e.message)
self.fail("validate_dependencies raised an exception: %s"
% e.message)
# Normalize then add conflicting constraints to the DAG (this is an
# extremely unlikely scenario, but we test for it anyway)

View file

@ -18,7 +18,7 @@ def check_satisfies(self, lspec, rspec):
l.constrain(r)
r.constrain(l)
except SpecError, e:
self.fail("Got a SpecError in constrain!", e.message)
self.fail("Got a SpecError in constrain! " + e.message)
def check_unsatisfiable(self, lspec, rspec):

View file

@ -42,7 +42,7 @@ def check_parse(self, expected, spec=None):
If this is called with two arguments, the first argument is the expected
canonical form and the second is a non-canonical input to be parsed.
"""
if spec == None:
if spec is None:
spec = expected
output = spack.spec.parse(spec)
parsed = (" ".join(str(spec) for spec in output))

View file

@ -51,7 +51,7 @@ class UndetectableNameError(UrlParseError):
"""Raised when we can't parse a package name from a string."""
def __init__(self, path):
super(UndetectableNameError, self).__init__(
"Couldn't parse package name in: " + path)
"Couldn't parse package name in: " + path, path)
def parse_version_string_with_indices(path):

View file

@ -10,7 +10,7 @@
def lt(lhs, rhs):
"""Less-than comparison. None is greater than any value."""
return lhs != rhs and (rhs == None or (lhs != None and lhs < rhs))
return lhs != rhs and (rhs is None or (lhs is not None and lhs < rhs))
def le(lhs, rhs):
@ -30,9 +30,9 @@ def ge(lhs, rhs):
def min(lhs, rhs):
"""Minimum function where None is greater than any value."""
if lhs == None:
if lhs is None:
return rhs
elif rhs == None:
elif rhs is None:
return lhs
else:
return _builtin_min(lhs, rhs)
@ -40,7 +40,7 @@ def min(lhs, rhs):
def max(lhs, rhs):
"""Maximum function where None is greater than any value."""
if lhs == None or rhs == None:
if lhs is None or rhs is None:
return None
else:
return _builtin_max(lhs, rhs)

View file

@ -10,7 +10,7 @@
def lt(lhs, rhs):
"""Less-than comparison. None is lower than any value."""
return lhs != rhs and (lhs == None or (rhs != None and lhs < rhs))
return lhs != rhs and (lhs is None or (rhs is not None and lhs < rhs))
def le(lhs, rhs):
@ -30,7 +30,7 @@ def ge(lhs, rhs):
def min(lhs, rhs):
"""Minimum function where None is less than any value."""
if lhs == None or rhs == None:
if lhs is None or rhs is None:
return None
else:
return _builtin_min(lhs, rhs)
@ -38,9 +38,9 @@ def min(lhs, rhs):
def max(lhs, rhs):
"""Maximum function where None is less than any value."""
if lhs == None:
if lhs is None:
return rhs
elif rhs == None:
elif rhs is None:
return lhs
else:
return _builtin_max(lhs, rhs)

View file

@ -299,9 +299,9 @@ def __contains__(self, other):
@coerced
def overlaps(self, other):
return (other in self or self in other or
((self.start == None or other.end == None or
((self.start == None or other.end is None or
self.start <= other.end) and
(other.start == None or self.end == None or
(other.start is None or self.end == None or
other.start <= self.end)))
@ -346,7 +346,7 @@ class VersionList(object):
"""Sorted, non-redundant list of Versions and VersionRanges."""
def __init__(self, vlist=None):
self.versions = []
if vlist != None:
if vlist is not None:
if isinstance(vlist, basestring):
vlist = _string_to_version(vlist)
if type(vlist) == VersionList: