Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Feb 3, 2016
1 parent fd206b7 commit 84e8c38
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
15 changes: 9 additions & 6 deletions scripts/check_matplotlib
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ import sys

# See if matplotlib is installed in the first place
try:
import matplotlib as mpl;
import matplotlib as mpl
except ImportError:
print("error: matplotlib is not installed. please install matplotlib v1.5.1 or later and try again.", file=sys.stderr)
sys.exit(-1)
print("error: matplotlib is not installed. Please install matplotlib v1.5.1 or later and try again.",
file=sys.stderr)
sys.exit(-1)

# See if the version is compatible
(major, minor, pl) = [ int(s) for s in (mpl.__version__ + ".0.0.0").split('.')[:3] ]
(major, minor, pl) = [int(s) for s in (mpl.__version__ + ".0.0.0").split('.')[:3]]
if (major < 1) or (major == 1 and minor < 2) or (major == 1 and minor == 2 and pl < 0):
print("error: matplotlib version too old (%s). please install matplotlib v1.2.0 or later and try again." % mpl.__version__, file=sys.stderr)
sys.exit(-1)
print("error: matplotlib version too old (%s)."
" Please install matplotlib v1.2.0 or later and try again." % mpl.__version__,
file=sys.stderr)
sys.exit(-1)

print("matplotlib version ok (%s)." % mpl.__version__)

Expand Down
47 changes: 26 additions & 21 deletions scripts/check_python_module
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,53 @@
#

from __future__ import print_function
import sys, os.path, importlib, argparse
import sys
import importlib
import argparse

parser = argparse.ArgumentParser(description="Check presence and version of a Python module")
parser.add_argument("module", help="python module to check")
parser.add_argument("min_version", help="minimum version")
parser.add_argument("-v", "--verbose", action="store_true")
args = parser.parse_args()

modname=args.module
version=args.min_version
modname = args.module
version = args.min_version

#
# See if numpy is installed in the first place
#
try:
module = importlib.import_module(modname)
module = importlib.import_module(modname)
except ImportError:
print("error: %(module)s is not installed. please install %(module)s v%(needver)s or later and try again." % {
'module' : modname,
'needver' : version
}, file=sys.stderr)
exit(-1)
print("error: %(module)s is not installed."
" Please install %(module)s v%(needver)s or later and try again." % {
'module': modname,
'needver': version
},
file=sys.stderr)
exit(-1)

#
# Check version compatibility
#
needver = list(map(int, version.split('.')))
havever = list(map(int, module.__version__.split('.'))) + [ 0 ] * len(needver)
havever = list(map(int, module.__version__.split('.'))) + [0] * len(needver)
for a, b in zip(needver, havever):
if a > b:
print("error: %(module)s version too old (v%(havever)s). please install %(module)s v%(needver)s or later and try again." % {
'module' : modname,
'havever' : module.__version__,
'needver' : version
}, file=sys.stderr)
exit(-1)
elif a < b:
break
if a > b:
print("error: %(module)s version too old (v%(havever)s)."
" Please install %(module)s v%(needver)s or later and try again." % {
'module': modname,
'havever': module.__version__,
'needver': version
},
file=sys.stderr)
exit(-1)
elif a < b:
break

if args.verbose:
print("Using externally provided %s v%s." % (modname, module.__version__))
# print "Located in '%s'." % os.path.dirname(module.__file__)
print("Using externally provided %s v%s." % (modname, module.__version__))

# OK.
exit(0)

0 comments on commit 84e8c38

Please sign in to comment.