From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id DE03913888F for ; Tue, 6 Oct 2015 04:23:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 13CDA21C012; Tue, 6 Oct 2015 04:23:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A2A5321C012 for ; Tue, 6 Oct 2015 04:23:21 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 6C4CA340884 for ; Tue, 6 Oct 2015 04:23:20 +0000 (UTC) From: Mike Frysinger To: gentoo-catalyst@lists.gentoo.org Subject: [gentoo-catalyst] [PATCH] lint: avoid redefining builtins Date: Tue, 6 Oct 2015 00:23:18 -0400 Message-Id: <1444105398-17405-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.5.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: 96348214-8f1a-4d9d-ab2d-97ff4c23832b X-Archives-Hash: 01a96465e04acbe1189c023144d275f7 It can be confusing to try and use builtins like str() when code is also declaring variables named "str". Avoid doing that everywhere. --- catalyst/base/genbase.py | 34 ++++++++++++++++++---------------- catalyst/support.py | 10 +++++----- 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 c05b36d..a163638 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 1e3eeef..90c59eb 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 db6a93f..4143359 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") -- 2.5.2