summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Gordon <jogo@cloudscaling.com>2013-02-25 17:00:38 -0800
committerAaron Rosen <arosen@nicira.com>2013-02-25 17:06:44 -0800
commit2f778241a378ba82ecbf819c021b4a1cce86caaa (patch)
treefd6e0852cd3a51cac3dbd93aab1b2cf0022d7c2c
parentd9bbcfb76646cb77d9dfc867f057917b3e059a4f (diff)
downloadnova-2f778241a378ba82ecbf819c021b4a1cce86caaa.tar.gz
nova-2f778241a378ba82ecbf819c021b4a1cce86caaa.tar.xz
nova-2f778241a378ba82ecbf819c021b4a1cce86caaa.zip
Fix hacking.py to handle parenthesise in from import as
Fix bug 1133070 Support 'from os import (path as p)' Change-Id: Ie2e5b3150efb6f47b16978f3de64fca37e1717a6
-rwxr-xr-xtools/hacking.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/hacking.py b/tools/hacking.py
index 1279e87e9..cfd8b8ffc 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -176,9 +176,12 @@ def nova_import_rules(logical_line):
Examples:
Okay: from os import path
+ Okay: from os import path as p
+ Okay: from os import (path as p)
Okay: import os.path
Okay: from nova.compute import rpcapi
N302: from os.path import dirname as dirname2
+ N302: from os.path import (dirname as dirname2)
N303: from os.path import *
N304: from .compute import rpcapi
"""
@@ -186,6 +189,7 @@ def nova_import_rules(logical_line):
# pass the doctest, since the relativity depends on the file's locality
def is_module_for_sure(mod, search_path=sys.path):
+ mod = mod.replace('(', '') # Ignore parentheses
try:
mod_name = mod
while '.' in mod_name: