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