diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-10-06 00:21:29 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-10-06 00:21:29 -0400 |
commit | 3a0aff0ef565404c78ca07bdfd01d42e9632912a (patch) | |
tree | 5d38d4edea5942e4784b916914ba105f28e88245 | |
parent | lint: clean up global statement warnings (diff) | |
download | catalyst-3a0aff0ef565404c78ca07bdfd01d42e9632912a.tar.gz catalyst-3a0aff0ef565404c78ca07bdfd01d42e9632912a.tar.bz2 catalyst-3a0aff0ef565404c78ca07bdfd01d42e9632912a.zip |
lint: avoid redefining builtins
It can be confusing to try and use builtins like str() when code is
also declaring variables named "str". Avoid doing that everywhere.
-rw-r--r-- | catalyst/base/genbase.py | 34 | ||||
-rw-r--r-- | catalyst/support.py | 10 | ||||
-rwxr-xr-x | targets/stage1/build.py | 8 |
3 files changed, 27 insertions, 25 deletions
diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py index c05b36d8..a1636386 100644 --- a/catalyst/base/genbase.py +++ b/catalyst/base/genbase.py @@ -11,48 +11,50 @@ class GenBase(object): self.settings = myspec - def gen_contents_file(self,file): - if os.path.exists(file+".CONTENTS"): - os.remove(file+".CONTENTS") + def gen_contents_file(self, path): + contents = path + ".CONTENTS" + if os.path.exists(contents): + os.remove(contents) if "contents" in self.settings: contents_map = self.settings["contents_map"] - if os.path.exists(file): - myf=open(file+".CONTENTS","w") + if os.path.exists(path): + myf = open(contents, "w") keys={} for i in self.settings["contents"].split(): keys[i]=1 array=keys.keys() array.sort() for j in array: - contents = contents_map.contents(file, j, + contents = contents_map.contents(path, j, verbose="VERBOSE" in self.settings) if contents: myf.write(contents) myf.close() - def gen_digest_file(self,file): - if os.path.exists(file+".DIGESTS"): - os.remove(file+".DIGESTS") + def gen_digest_file(self, path): + digests = path + ".DIGESTS" + if os.path.exists(digests): + os.remove(digests) if "digests" in self.settings: hash_map = self.settings["hash_map"] - if os.path.exists(file): - myf=open(file+".DIGESTS","w") + if os.path.exists(path): + myf=open(digests, "w") keys={} for i in self.settings["digests"].split(): keys[i]=1 array=keys.keys() array.sort() - for f in [file, file+'.CONTENTS']: + for f in [path, path + '.CONTENTS']: if os.path.exists(f): if "all" in array: for k in list(hash_map.hash_map): - hash = hash_map.generate_hash(f,hash_=k, + digest = hash_map.generate_hash(f,hash_=k, verbose = "VERBOSE" in self.settings) - myf.write(hash) + myf.write(digest) else: for j in array: - hash = hash_map.generate_hash(f,hash_=j, + digest = hash_map.generate_hash(f,hash_=j, verbose = "VERBOSE" in self.settings) - myf.write(hash) + myf.write(digest) myf.close() diff --git a/catalyst/support.py b/catalyst/support.py index 1e3eeefc..90c59eb9 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -34,23 +34,23 @@ spawned_pids = [] # a function to turn a string of non-printable characters # into a string of hex characters -def hexify(str): +def hexify(s): hexStr = string.hexdigits r = '' - for ch in str: + for ch in s: i = ord(ch) r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF] return r -def read_from_clst(file): +def read_from_clst(path): line = '' myline = '' try: - myf=open(file,"r") + myf = open(path, "r") except: return -1 - #raise CatalystError("Could not open file "+file) + #raise CatalystError("Could not open file " + path) for line in myf.readlines(): #line = line.replace("\n", "") # drop newline myline = myline + line diff --git a/targets/stage1/build.py b/targets/stage1/build.py index db6a93fe..6495ee39 100755 --- a/targets/stage1/build.py +++ b/targets/stage1/build.py @@ -8,14 +8,14 @@ import portage # wrap it here to take care of the different # ways portage handles stacked profiles # last case is for portage-2.1_pre* -def scan_profile(file): +def scan_profile(path): if "grab_stacked" in dir(portage): - return portage.grab_stacked(file, portage.settings.profiles, portage.grabfile, incremental_lines=1) + return portage.grab_stacked(path, portage.settings.profiles, portage.grabfile, incremental_lines=1) else: if "grab_multiple" in dir(portage): - return portage.stack_lists( portage.grab_multiple(file, portage.settings.profiles, portage.grabfile), incremental=1) + return portage.stack_lists(portage.grab_multiple(path, portage.settings.profiles, portage.grabfile), incremental=1) else: - return portage.stack_lists( [portage.grabfile_package(os.path.join(x, file)) for x in portage.settings.profiles], incremental=1) + return portage.stack_lists([portage.grabfile_package(os.path.join(x, path)) for x in portage.settings.profiles], incremental=1) # loaded the stacked packages / packages.build files pkgs = scan_profile("packages") |