summaryrefslogtreecommitdiff
path: root/tools/hacking.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/hacking.py')
-rwxr-xr-xtools/hacking.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/hacking.py b/tools/hacking.py
index 75c795b9ca..7aa756bb5b 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2012, Cloudscaling
@@ -24,10 +25,10 @@ import inspect
import os
import re
import sys
-import traceback
import pep8
+
#N1xx comments
#N2xx except
#N3xx imports
@@ -118,14 +119,14 @@ def nova_import_module_only(logical_line):
return logical_line.find(mod), ("NOVA N302: import only "
"modules. '%s' does not import a module" % logical_line)
- except (ImportError, NameError):
+ except (ImportError, NameError) as exc:
if not added:
added = True
sys.path.append(current_path)
return importModuleCheck(mod, parent, added)
else:
- print >> sys.stderr, ("ERROR: import '%s' failed, couldn't "
- "find module" % logical_line)
+ print >> sys.stderr, ("ERROR: import '%s' failed: %s" %
+ (logical_line, exc))
added = False
sys.path.pop()
return
@@ -149,6 +150,7 @@ def nova_import_module_only(logical_line):
# handle "from x import y as z"
elif (logical_line.startswith("from ") and "," not in logical_line and
split_line[2] == "import" and split_line[3] != "*" and
+ split_line[1] != "__future__" and
(len(split_line) == 4 or
(len(split_line) == 6 and split_line[4] == "as"))):
mod = split_line[3]