diff options
author | Devan Franchini <twitch153@gentoo.org> | 2014-04-26 15:29:23 -0400 |
---|---|---|
committer | Devan Franchini <twitch153@gentoo.org> | 2015-06-19 15:44:08 -0400 |
commit | 2909c15aff1eb419a7d705067864ac6b90ecf097 (patch) | |
tree | 49a0385518a880e5d518f349d7e8d6bbfa890518 | |
parent | sbin/webapp-cleaner: alters source to /lib/gentoo/functions.sh (diff) | |
download | webapp-config-2909c15aff1eb419a7d705067864ac6b90ecf097.tar.gz webapp-config-2909c15aff1eb419a7d705067864ac6b90ecf097.tar.bz2 webapp-config-2909c15aff1eb419a7d705067864ac6b90ecf097.zip |
Adds python3.x compatibility to codebase.
Although most of the codebase already has python3.x compatibility
when running 2to3 more minor changes where found. This commit
includes the changes found when running 2to3 on webapp-config's
codebase.
-rw-r--r-- | WebappConfig/config.py | 4 | ||||
-rw-r--r-- | WebappConfig/content.py | 22 | ||||
-rw-r--r-- | WebappConfig/db.py | 4 | ||||
-rw-r--r-- | WebappConfig/debug.py | 8 | ||||
-rw-r--r-- | WebappConfig/dotconfig.py | 6 | ||||
-rw-r--r-- | WebappConfig/ebuild.py | 2 | ||||
-rw-r--r-- | WebappConfig/filetype.py | 6 | ||||
-rw-r--r-- | WebappConfig/sandbox.py | 4 |
8 files changed, 28 insertions, 28 deletions
diff --git a/WebappConfig/config.py b/WebappConfig/config.py index 1f3fab1..597dc18 100644 --- a/WebappConfig/config.py +++ b/WebappConfig/config.py @@ -857,7 +857,7 @@ class Config: OUT.debug('Trying to import environment variables', 7) if envmap: - for (key, value) in os.environ.items(): + for (key, value) in list(os.environ.items()): if envmap == 'all' or key.lower() in envmap: @@ -894,7 +894,7 @@ class Config: 'verbose' : 'g_verbose', 'bug_report' : 'g_bugreport'} - for i in option_to_config.keys(): + for i in list(option_to_config.keys()): if i in options.__dict__ and options.__dict__[i]: self.config.set('USER', option_to_config[i], str(options.__dict__[i])) diff --git a/WebappConfig/content.py b/WebappConfig/content.py index c635f5a..e157d23 100644 --- a/WebappConfig/content.py +++ b/WebappConfig/content.py @@ -291,7 +291,7 @@ class Contents: self.check_installdir() - values = [' '.join(i) for i in self.__content.values()] + values = [' '.join(i) for i in list(self.__content.values())] if not self.__p: try: @@ -481,7 +481,7 @@ class Contents: 'sym' : [ 'sym', self.file_zero, self.file_link ], } - if not dsttype in allowed_types.keys(): + if not dsttype in list(allowed_types.keys()): OUT.die('Oops, webapp-config bug. "dsttype" is ' + dsttype) # Generate handler for file attributes @@ -548,7 +548,7 @@ class Contents: ''' Get a list of files. This is returned as a list sorted according to length, so that files lower in the hierarchy can be removed first.''' - installed = self.__content.keys() + installed = list(self.__content.keys()) return sorted(installed, key=lambda x: (-len(x), x)) def get_directories(self): @@ -675,7 +675,7 @@ class Contents: def entry(self, entry): ''' Return a complete entry.''' - if entry in self.__content.keys(): + if entry in list(self.__content.keys()): return ' '.join(self.__content[entry]) else: raise Exception('Unknown file "' + entry + '"') @@ -684,7 +684,7 @@ class Contents: ''' Returns the entry type. ''' - if entry in self.__content.keys(): + if entry in list(self.__content.keys()): return self.__content[entry][0] else: raise Exception('Unknown file "' + entry + '"') @@ -693,7 +693,7 @@ class Contents: ''' Returns if the entry is relative or not. ''' - if entry in self.__content.keys(): + if entry in list(self.__content.keys()): return bool(int(self.__content[entry][1])) else: raise Exception('Unknown file "' + entry + '"') @@ -702,7 +702,7 @@ class Contents: ''' Returns the owner of the entry. ''' - if entry in self.__content.keys(): + if entry in list(self.__content.keys()): return self.__content[entry][2] else: raise Exception('Unknown file "' + entry + '"') @@ -711,7 +711,7 @@ class Contents: ''' Returns the (possibly relative) path of the entry. ''' - if entry in self.__content.keys(): + if entry in list(self.__content.keys()): msg = self.__content[entry][3] if msg[0] == "/": msg = self.__root + msg @@ -724,7 +724,7 @@ class Contents: ''' Returns the recorded modification time of the entry. ''' - if entry in self.__content.keys(): + if entry in list(self.__content.keys()): return self.__content[entry][4] else: raise Exception('Unknown file "' + entry + '"') @@ -733,7 +733,7 @@ class Contents: ''' Returns the recorded md5 hash of the entry. ''' - if entry in self.__content.keys(): + if entry in list(self.__content.keys()): return self.__content[entry][5] else: raise Exception('Unknown file "' + entry + '"') @@ -742,7 +742,7 @@ class Contents: ''' Returns the recorded target of the link. ''' - if entry in self.__content.keys(): + if entry in list(self.__content.keys()): return self.__content[entry][6] else: raise Exception('Unknown file "' + entry + '"') diff --git a/WebappConfig/db.py b/WebappConfig/db.py index 2d70cb9..aa33ac5 100644 --- a/WebappConfig/db.py +++ b/WebappConfig/db.py @@ -405,7 +405,7 @@ class WebappDB(AppHierarchy): result = {} - for j in files.keys(): + for j in list(files.keys()): if files[j][0]: p = files[j][0] + '/' + files[j][1] + '-' + files[j][2] @@ -452,7 +452,7 @@ class WebappDB(AppHierarchy): OUT.warn('Assuming webapp is no longer installed.') OUT.warn('Pruning entry from database.') if action == 'clean': - for installs in files.keys(): + for installs in list(files.keys()): contents = open(installs).readlines() new_entries = '' for entry in contents: diff --git a/WebappConfig/debug.py b/WebappConfig/debug.py index 5482f43..1e6bd2c 100644 --- a/WebappConfig/debug.py +++ b/WebappConfig/debug.py @@ -395,7 +395,7 @@ class Message: callerlocals = inspect.getargvalues(caller[0])[3] ## Is the caller an obejct? If so he provides 'self' - if 'self' in callerlocals.keys(): + if 'self' in list(callerlocals.keys()): callerobject = callerlocals['self'] del callerlocals['self'] if self.show_class_variables: @@ -407,7 +407,7 @@ class Message: # Remove variables not requested if not '*' in self.debug_var: - callerlocals = dict([i for i in callerlocals.items() + callerlocals = dict([i for i in list(callerlocals.items()) if i[0] in self.debug_var]) ## Is the object among the list of objects to debug? @@ -445,7 +445,7 @@ class Message: print('// ' + c, file=self.debug_out) # Selected variables follow if callerlocals: - for i,j in callerlocals.items(): + for i,j in list(callerlocals.items()): print('// ' \ + self.maybe_color('turquoise', str(i)) + ':' + str(j), file=self.debug_out) # Finally the message @@ -480,7 +480,7 @@ class Message: if self.debug_vrb == 3: print(ls + '//', file=self.debug_out) print(ls + '// VALUES ', file=self.debug_out) - for i,j in callerlocals.items(): + for i,j in list(callerlocals.items()): print(ls + '// ------------------> ' \ + self.maybe_color('turquoise', str(i)) + ':', file=self.debug_out) breaklines(str(j)) diff --git a/WebappConfig/dotconfig.py b/WebappConfig/dotconfig.py index cab0392..948fa90 100644 --- a/WebappConfig/dotconfig.py +++ b/WebappConfig/dotconfig.py @@ -115,7 +115,7 @@ class DotConfig: 'WEB_INSTALLDIR'] def __getitem__(self, key): - if key in self.__data.keys(): + if key in list(self.__data.keys()): return self.__data[key] # this key didn't exist in old versions, but new versions # expect it. fix bug 355295 @@ -180,8 +180,8 @@ class DotConfig: OUT.debug('Trying to retrieve package name', 6) - if 'WEB_PN' in self.__data.keys() and 'WEB_PVR' in self.__data.keys(): - if 'WEB_CATEGORY' in self.__data.keys(): + if 'WEB_PN' in list(self.__data.keys()) and 'WEB_PVR' in list(self.__data.keys()): + if 'WEB_CATEGORY' in list(self.__data.keys()): return self.__data['WEB_CATEGORY'] + '/' + \ self.__data['WEB_PN'] + '-' + self.__data['WEB_PVR'] else: diff --git a/WebappConfig/ebuild.py b/WebappConfig/ebuild.py index 29ec893..24ef0d6 100644 --- a/WebappConfig/ebuild.py +++ b/WebappConfig/ebuild.py @@ -326,7 +326,7 @@ class Ebuild: 'PVR': None} result = {} - for i in export_map.keys(): + for i in list(export_map.keys()): value = export_map[i] diff --git a/WebappConfig/filetype.py b/WebappConfig/filetype.py index 3c5acbb..63d7e5f 100644 --- a/WebappConfig/filetype.py +++ b/WebappConfig/filetype.py @@ -137,7 +137,7 @@ class FileType: for i in server_owned: - if self.__fix(i) in self.__cache.keys(): + if self.__fix(i) in list(self.__cache.keys()): OUT.debug('Adding config-server-owned file', 8) @@ -177,7 +177,7 @@ class FileType: filename = self.__fix(filename) # look for config-protected files in the cache - if filename in self.__cache.keys(): + if filename in list(self.__cache.keys()): return self.__cache[filename] # unspecified file (and thus virtual) @@ -208,7 +208,7 @@ class FileType: directory = self.__fix(directory) # check the cache - if directory in self.__cache.keys(): + if directory in list(self.__cache.keys()): return self.__cache[directory] # unspecified directories are default-owned diff --git a/WebappConfig/sandbox.py b/WebappConfig/sandbox.py index 3a86673..0cac7e1 100644 --- a/WebappConfig/sandbox.py +++ b/WebappConfig/sandbox.py @@ -35,7 +35,7 @@ if os.path.isdir("/proc/%i/fd" % os.getpid()): return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) if fd.isdigit()) else: def get_open_fds(): - return range(max_fd_limit) + return list(range(max_fd_limit)) class Sandbox: @@ -88,7 +88,7 @@ class Sandbox: # merge full_env (w-c variables) with env (write path) self.env.update(full_env) - for a in self.env.keys(): + for a in list(self.env.keys()): if not self.env[a]: self.env[a] = '' |