1 |
commit: 3a0aff0ef565404c78ca07bdfd01d42e9632912a |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Oct 6 04:21:29 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Oct 6 04:21:29 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3a0aff0e |
7 |
|
8 |
lint: avoid redefining builtins |
9 |
|
10 |
It can be confusing to try and use builtins like str() when code is |
11 |
also declaring variables named "str". Avoid doing that everywhere. |
12 |
|
13 |
catalyst/base/genbase.py | 34 ++++++++++++++++++---------------- |
14 |
catalyst/support.py | 10 +++++----- |
15 |
targets/stage1/build.py | 8 ++++---- |
16 |
3 files changed, 27 insertions(+), 25 deletions(-) |
17 |
|
18 |
diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py |
19 |
index c05b36d..a163638 100644 |
20 |
--- a/catalyst/base/genbase.py |
21 |
+++ b/catalyst/base/genbase.py |
22 |
@@ -11,48 +11,50 @@ class GenBase(object): |
23 |
self.settings = myspec |
24 |
|
25 |
|
26 |
- def gen_contents_file(self,file): |
27 |
- if os.path.exists(file+".CONTENTS"): |
28 |
- os.remove(file+".CONTENTS") |
29 |
+ def gen_contents_file(self, path): |
30 |
+ contents = path + ".CONTENTS" |
31 |
+ if os.path.exists(contents): |
32 |
+ os.remove(contents) |
33 |
if "contents" in self.settings: |
34 |
contents_map = self.settings["contents_map"] |
35 |
- if os.path.exists(file): |
36 |
- myf=open(file+".CONTENTS","w") |
37 |
+ if os.path.exists(path): |
38 |
+ myf = open(contents, "w") |
39 |
keys={} |
40 |
for i in self.settings["contents"].split(): |
41 |
keys[i]=1 |
42 |
array=keys.keys() |
43 |
array.sort() |
44 |
for j in array: |
45 |
- contents = contents_map.contents(file, j, |
46 |
+ contents = contents_map.contents(path, j, |
47 |
verbose="VERBOSE" in self.settings) |
48 |
if contents: |
49 |
myf.write(contents) |
50 |
myf.close() |
51 |
|
52 |
- def gen_digest_file(self,file): |
53 |
- if os.path.exists(file+".DIGESTS"): |
54 |
- os.remove(file+".DIGESTS") |
55 |
+ def gen_digest_file(self, path): |
56 |
+ digests = path + ".DIGESTS" |
57 |
+ if os.path.exists(digests): |
58 |
+ os.remove(digests) |
59 |
if "digests" in self.settings: |
60 |
hash_map = self.settings["hash_map"] |
61 |
- if os.path.exists(file): |
62 |
- myf=open(file+".DIGESTS","w") |
63 |
+ if os.path.exists(path): |
64 |
+ myf=open(digests, "w") |
65 |
keys={} |
66 |
for i in self.settings["digests"].split(): |
67 |
keys[i]=1 |
68 |
array=keys.keys() |
69 |
array.sort() |
70 |
- for f in [file, file+'.CONTENTS']: |
71 |
+ for f in [path, path + '.CONTENTS']: |
72 |
if os.path.exists(f): |
73 |
if "all" in array: |
74 |
for k in list(hash_map.hash_map): |
75 |
- hash = hash_map.generate_hash(f,hash_=k, |
76 |
+ digest = hash_map.generate_hash(f,hash_=k, |
77 |
verbose = "VERBOSE" in self.settings) |
78 |
- myf.write(hash) |
79 |
+ myf.write(digest) |
80 |
else: |
81 |
for j in array: |
82 |
- hash = hash_map.generate_hash(f,hash_=j, |
83 |
+ digest = hash_map.generate_hash(f,hash_=j, |
84 |
verbose = "VERBOSE" in self.settings) |
85 |
- myf.write(hash) |
86 |
+ myf.write(digest) |
87 |
myf.close() |
88 |
|
89 |
|
90 |
diff --git a/catalyst/support.py b/catalyst/support.py |
91 |
index 1e3eeef..90c59eb 100644 |
92 |
--- a/catalyst/support.py |
93 |
+++ b/catalyst/support.py |
94 |
@@ -34,23 +34,23 @@ spawned_pids = [] |
95 |
|
96 |
# a function to turn a string of non-printable characters |
97 |
# into a string of hex characters |
98 |
-def hexify(str): |
99 |
+def hexify(s): |
100 |
hexStr = string.hexdigits |
101 |
r = '' |
102 |
- for ch in str: |
103 |
+ for ch in s: |
104 |
i = ord(ch) |
105 |
r = r + hexStr[(i >> 4) & 0xF] + hexStr[i & 0xF] |
106 |
return r |
107 |
|
108 |
|
109 |
-def read_from_clst(file): |
110 |
+def read_from_clst(path): |
111 |
line = '' |
112 |
myline = '' |
113 |
try: |
114 |
- myf=open(file,"r") |
115 |
+ myf = open(path, "r") |
116 |
except: |
117 |
return -1 |
118 |
- #raise CatalystError("Could not open file "+file) |
119 |
+ #raise CatalystError("Could not open file " + path) |
120 |
for line in myf.readlines(): |
121 |
#line = line.replace("\n", "") # drop newline |
122 |
myline = myline + line |
123 |
|
124 |
diff --git a/targets/stage1/build.py b/targets/stage1/build.py |
125 |
index db6a93f..6495ee3 100755 |
126 |
--- a/targets/stage1/build.py |
127 |
+++ b/targets/stage1/build.py |
128 |
@@ -8,14 +8,14 @@ import portage |
129 |
# wrap it here to take care of the different |
130 |
# ways portage handles stacked profiles |
131 |
# last case is for portage-2.1_pre* |
132 |
-def scan_profile(file): |
133 |
+def scan_profile(path): |
134 |
if "grab_stacked" in dir(portage): |
135 |
- return portage.grab_stacked(file, portage.settings.profiles, portage.grabfile, incremental_lines=1) |
136 |
+ return portage.grab_stacked(path, portage.settings.profiles, portage.grabfile, incremental_lines=1) |
137 |
else: |
138 |
if "grab_multiple" in dir(portage): |
139 |
- return portage.stack_lists( portage.grab_multiple(file, portage.settings.profiles, portage.grabfile), incremental=1) |
140 |
+ return portage.stack_lists(portage.grab_multiple(path, portage.settings.profiles, portage.grabfile), incremental=1) |
141 |
else: |
142 |
- return portage.stack_lists( [portage.grabfile_package(os.path.join(x, file)) for x in portage.settings.profiles], incremental=1) |
143 |
+ return portage.stack_lists([portage.grabfile_package(os.path.join(x, path)) for x in portage.settings.profiles], incremental=1) |
144 |
|
145 |
# loaded the stacked packages / packages.build files |
146 |
pkgs = scan_profile("packages") |