Add global declaration to var _LOOP_RULE_PTH
authorHuang Hao <hao.h.huang@intel.com>
Mon, 18 Feb 2013 09:19:32 +0000 (17:19 +0800)
committerHuang Hao <hao.h.huang@intel.com>
Mon, 18 Feb 2013 09:19:32 +0000 (17:19 +0800)
hide_loopdev_presentation() redefine a var with the same name
_LOOP_RULE_PTH by setting its value without global statement. and
its global counterpart can never be changed.

pylint message:
W0621:136,12:hide_loopdev_presentation: Redefining name '_LOOP_RULE_PTH' from outer scope (line 125)

Change-Id: I1cfafa46a933e22c732d4f4963c4a4f6d1ac4c1d

mic/utils/misc.py

index dd754ed..79a6c18 100644 (file)
@@ -123,6 +123,7 @@ def get_distro_str():
         return distro_str.strip()
 
 _LOOP_RULE_PTH = None
+
 def hide_loopdev_presentation():
     udev_rules = "80-prevent-loop-present.rules"
     udev_rules_dir = [
@@ -131,6 +132,8 @@ def hide_loopdev_presentation():
                        '/etc/udev/rules.d/'
                      ]
 
+    global _LOOP_RULE_PTH
+
     for rdir in udev_rules_dir:
         if os.path.exists(rdir):
             _LOOP_RULE_PTH = os.path.join(rdir, udev_rules)
@@ -147,6 +150,8 @@ def hide_loopdev_presentation():
         pass
 
 def unhide_loopdev_presentation():
+    global _LOOP_RULE_PTH
+
     if not _LOOP_RULE_PTH:
         return
 
@@ -706,7 +711,7 @@ def get_arch(repometadata):
                  uniq_arch.append(archlist[i])
 
         return uniq_arch
-    
+
 
     ret_uniq_arch = []
     ret_arch_list = []
@@ -731,7 +736,7 @@ def get_arch(repometadata):
 
         uniq_arch = uniqarch(archlist)
         if not ret_uniq_arch and len(uniq_arch) == 1:
-            ret_uniq_arch = uniq_arch 
+            ret_uniq_arch = uniq_arch
         ret_arch_list += uniq_arch
 
     ret_arch_list = uniqarch(ret_arch_list)