Permalink
Browse files

Clean: Remove some nesting levels.

  • Loading branch information...
1 parent 57e96e8 commit 475756a9e86c6df947546def197e32db32ecdb56 @htgoebel htgoebel committed Mar 27, 2012
Showing with 44 additions and 43 deletions.
  1. +21 −20 PyInstaller/depend/impdirector.py
  2. +23 −23 PyInstaller/loader/iu.py
@@ -69,26 +69,27 @@ def __init__(self):
import win32api
import win32con
except ImportError:
- pass
- else:
- subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver
- for root in (win32con.HKEY_CURRENT_USER, win32con.HKEY_LOCAL_MACHINE):
- try:
- hkey = win32api.RegOpenKeyEx(root, subkey, 0, win32con.KEY_READ)
- except Exception, e:
- logger.debug('RegistryImportDirector: %s' % e)
- else:
- numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey)
- for i in range(numsubkeys):
- subkeyname = win32api.RegEnumKey(hkey, i)
- hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, win32con.KEY_READ)
- val = win32api.RegQueryValueEx(hskey, '')
- desc = getDescr(val[0])
- #print " RegistryImportDirector got %s %s" % (val[0], desc) #XXX
- self.map[subkeyname] = (val[0], desc)
- hskey.Close()
- hkey.Close()
- break
+ return
+
+ subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver
+ for root in (win32con.HKEY_CURRENT_USER, win32con.HKEY_LOCAL_MACHINE):
+ try:
+ hkey = win32api.RegOpenKeyEx(root, subkey, 0, win32con.KEY_READ)
+ except Exception, e:
+ logger.debug('RegistryImportDirector: %s' % e)
+ continue
+
+ numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey)
+ for i in range(numsubkeys):
+ subkeyname = win32api.RegEnumKey(hkey, i)
+ hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, win32con.KEY_READ)
+ val = win32api.RegQueryValueEx(hskey, '')
+ desc = getDescr(val[0])
+ #print " RegistryImportDirector got %s %s" % (val[0], desc) #XXX
+ self.map[subkeyname] = (val[0], desc)
+ hskey.Close()
+ hkey.Close()
+ break
def getmod(self, nm, loadco=marshal.loads):
stuff = self.map.get(nm)
View
@@ -231,29 +231,29 @@ def __init__(self):
try:
import win32api
except ImportError:
- pass
- else:
- HKEY_CURRENT_USER = -2147483647
- HKEY_LOCAL_MACHINE = -2147483646
- KEY_READ = 131097
- subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver
- for root in (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE):
- try:
- hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_READ)
- except Exception:
- # If the key does not exist, simply try the next one.
- pass
- else:
- numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey)
- for i in range(numsubkeys):
- subkeyname = win32api.RegEnumKey(hkey, i)
- hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, KEY_READ)
- val = win32api.RegQueryValueEx(hskey, '')
- desc = getDescr(val[0])
- self.map[subkeyname] = (val[0], desc)
- hskey.Close()
- hkey.Close()
- break
+ return
+
+ HKEY_CURRENT_USER = -2147483647
+ HKEY_LOCAL_MACHINE = -2147483646
+ KEY_READ = 131097
+ subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver
+ for root in (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE):
+ try:
+ hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_READ)
+ except Exception:
+ # If the key does not exist, simply try the next one.
+ continue
+
+ numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey)
+ for i in range(numsubkeys):
+ subkeyname = win32api.RegEnumKey(hkey, i)
+ hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, KEY_READ)
+ val = win32api.RegQueryValueEx(hskey, '')
+ desc = getDescr(val[0])
+ self.map[subkeyname] = (val[0], desc)
+ hskey.Close()
+ hkey.Close()
+ break
def getmod(self, nm):
stuff = self.map.get(nm)

0 comments on commit 475756a

Please sign in to comment.