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