1 |
commit: 97c96c8f6d616889bf9dcc423f27675c11af4af8 |
2 |
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Mar 28 02:52:48 2011 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Mon Mar 28 02:52:48 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=97c96c8f |
7 |
|
8 |
migrate to using explicit checks. |
9 |
|
10 |
--- |
11 |
layman/api.py | 4 ++-- |
12 |
layman/argsparser.py | 2 +- |
13 |
layman/db.py | 2 +- |
14 |
layman/dbbase.py | 6 +++--- |
15 |
layman/overlays/bzr.py | 4 ++-- |
16 |
layman/overlays/cvs.py | 4 ++-- |
17 |
layman/overlays/darcs.py | 4 ++-- |
18 |
layman/overlays/git.py | 4 ++-- |
19 |
layman/overlays/mercurial.py | 4 ++-- |
20 |
layman/overlays/overlay.py | 2 +- |
21 |
layman/overlays/rsync.py | 2 +- |
22 |
layman/overlays/source.py | 6 +++--- |
23 |
layman/overlays/svn.py | 4 ++-- |
24 |
layman/utils.py | 2 +- |
25 |
14 files changed, 25 insertions(+), 25 deletions(-) |
26 |
|
27 |
diff --git a/layman/api.py b/layman/api.py |
28 |
index 11fef62..cbb9d99 100644 |
29 |
--- a/layman/api.py |
30 |
+++ b/layman/api.py |
31 |
@@ -49,7 +49,7 @@ class LaymanAPI(object): |
32 |
default is Message(module='layman') other params are defaults. |
33 |
""" |
34 |
|
35 |
- self.config = config if config else BareConfig(output=output) |
36 |
+ self.config = config if config is not None else BareConfig(output=output) |
37 |
|
38 |
self.output = self.config['output'] |
39 |
|
40 |
@@ -433,7 +433,7 @@ class LaymanAPI(object): |
41 |
@rtype: list |
42 |
@return: list of error strings |
43 |
""" |
44 |
- if self._error_messages: |
45 |
+ if len(self._error_messages): |
46 |
messages = self._error_messages[:] |
47 |
self._error_messages = [] |
48 |
return messages |
49 |
|
50 |
diff --git a/layman/argsparser.py b/layman/argsparser.py |
51 |
index 708b1f8..9b6aa91 100644 |
52 |
--- a/layman/argsparser.py |
53 |
+++ b/layman/argsparser.py |
54 |
@@ -272,7 +272,7 @@ class ArgsParser(BareConfig): |
55 |
overlays = '\n'.join(self.options.__dict__[key]) |
56 |
if self.config.has_option('MAIN', 'overlays'): |
57 |
overlays += '\n' + self.config.get('MAIN', 'overlays') |
58 |
- if overlays: |
59 |
+ if len(overlays): |
60 |
return overlays |
61 |
|
62 |
self.output.debug('Retrieving option', 8) |
63 |
|
64 |
diff --git a/layman/db.py b/layman/db.py |
65 |
index 6e3cba4..aaba2b7 100644 |
66 |
--- a/layman/db.py |
67 |
+++ b/layman/db.py |
68 |
@@ -240,7 +240,7 @@ class RemoteDB(DbBase): |
69 |
opener = urllib2.build_opener(proxy_handler) |
70 |
urllib2.install_opener(opener) |
71 |
|
72 |
- self.urls = [i.strip() for i in config['overlays'].split('\n') if i] |
73 |
+ self.urls = [i.strip() for i in config['overlays'].split('\n') if len(i)] |
74 |
|
75 |
paths = [self.path(i) for i in self.urls] |
76 |
|
77 |
|
78 |
diff --git a/layman/dbbase.py b/layman/dbbase.py |
79 |
index 5c45cb1..70d0cfa 100644 |
80 |
--- a/layman/dbbase.py |
81 |
+++ b/layman/dbbase.py |
82 |
@@ -164,9 +164,9 @@ class DbBase: |
83 |
'''Reads xml text and dictionary definitions and adds |
84 |
them to the db. |
85 |
''' |
86 |
- if xml: |
87 |
+ if xml is not None: |
88 |
self.read(xml, origin) |
89 |
- if from_dict: |
90 |
+ if from_dict is not None: |
91 |
self.output.info("DbBase: add_new() from_dict") |
92 |
if isinstance(from_dict, dict): |
93 |
from_dict = [from_dict] |
94 |
@@ -272,7 +272,7 @@ class DbBase: |
95 |
result = [] |
96 |
|
97 |
selection = [overlay for (a, overlay) in self.overlays.items()] |
98 |
- if repos: |
99 |
+ if repos is not None: |
100 |
selection = [overlay for overlay in selection if overlay.name in repos] |
101 |
|
102 |
for overlay in selection: |
103 |
|
104 |
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py |
105 |
index 957f9e7..ec57a7b 100644 |
106 |
--- a/layman/overlays/bzr.py |
107 |
+++ b/layman/overlays/bzr.py |
108 |
@@ -55,7 +55,7 @@ class BzrOverlay(OverlaySource): |
109 |
target = path([base, self.parent.name]) |
110 |
|
111 |
# bzr get SOURCE TARGET |
112 |
- if cfg_opts: |
113 |
+ if len(cfg_opts): |
114 |
args = ['get', cfg_opts, |
115 |
self.src + '/', target] |
116 |
else: |
117 |
@@ -73,7 +73,7 @@ class BzrOverlay(OverlaySource): |
118 |
target = path([base, self.parent.name]) |
119 |
|
120 |
# bzr pull --overwrite SOURCE |
121 |
- if cfg_opts: |
122 |
+ if len(cfg_opts): |
123 |
args = ['pull', cfg_opts, '--overwrite', self.src] |
124 |
else: |
125 |
args = ['pull', '--overwrite', self.src] |
126 |
|
127 |
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py |
128 |
index 69e0dd1..15a6c97 100644 |
129 |
--- a/layman/overlays/cvs.py |
130 |
+++ b/layman/overlays/cvs.py |
131 |
@@ -76,7 +76,7 @@ class CvsOverlay(OverlaySource): |
132 |
args.append('-q') |
133 |
args.append('co') |
134 |
args.append('-d') |
135 |
- if cfg_opts: |
136 |
+ if len(cfg_opts): |
137 |
args.append(cfg_opts) |
138 |
args.append(self.parent.name) |
139 |
args.append(self.subpath) |
140 |
@@ -100,7 +100,7 @@ class CvsOverlay(OverlaySource): |
141 |
args.append('-q') |
142 |
args.append('update') |
143 |
args.append('-d') |
144 |
- if cfg_opts: |
145 |
+ if len(cfg_opts): |
146 |
args.append(cfg_opts) |
147 |
return self.postsync( |
148 |
self.run_command(self.command(), *args, cwd=target, cmd=self.type), |
149 |
|
150 |
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py |
151 |
index 14a415b..358db2d 100644 |
152 |
--- a/layman/overlays/darcs.py |
153 |
+++ b/layman/overlays/darcs.py |
154 |
@@ -54,7 +54,7 @@ class DarcsOverlay(OverlaySource): |
155 |
target = path([base, self.parent.name]) |
156 |
|
157 |
# darcs get --partial SOURCE TARGET |
158 |
- if cfg_opts: |
159 |
+ if len(cfg_opts): |
160 |
args = ['get', '--partial', cfg_opts, |
161 |
self.src + '/', target] |
162 |
else: |
163 |
@@ -74,7 +74,7 @@ class DarcsOverlay(OverlaySource): |
164 |
target = path([base, self.parent.name]) |
165 |
|
166 |
# darcs pull --all SOURCE |
167 |
- if cfg_opts: |
168 |
+ if len(cfg_opts): |
169 |
args = ['pull', '--all', cfg_opts, self.src] |
170 |
else: |
171 |
args = ['pull', '--all', self.src] |
172 |
|
173 |
diff --git a/layman/overlays/git.py b/layman/overlays/git.py |
174 |
index d65a5d3..1825f92 100644 |
175 |
--- a/layman/overlays/git.py |
176 |
+++ b/layman/overlays/git.py |
177 |
@@ -62,7 +62,7 @@ class GitOverlay(OverlaySource): |
178 |
args = ['clone'] |
179 |
if quiet: |
180 |
args.append('-q') |
181 |
- if cfg_opts: |
182 |
+ if len(cfg_opts): |
183 |
args.append(cfg_opts) |
184 |
args.append(fix_git_source(self.src)) |
185 |
args.append(target) |
186 |
@@ -81,7 +81,7 @@ class GitOverlay(OverlaySource): |
187 |
args = ['pull'] |
188 |
if quiet: |
189 |
args.append('-q') |
190 |
- if cfg_opts: |
191 |
+ if len(cfg_opts): |
192 |
args.append(cfg_opts) |
193 |
return self.postsync( |
194 |
self.run_command(self.command(), *args, cwd=target, cmd=self.type), |
195 |
|
196 |
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py |
197 |
index 748588b..c6a9fce 100644 |
198 |
--- a/layman/overlays/mercurial.py |
199 |
+++ b/layman/overlays/mercurial.py |
200 |
@@ -55,7 +55,7 @@ class MercurialOverlay(OverlaySource): |
201 |
target = path([base, self.parent.name]) |
202 |
|
203 |
# hg clone SOURCE TARGET |
204 |
- if cfg_opts: |
205 |
+ if len(cfg_opts): |
206 |
args = ['clone', cfg_opts, self.src + '/', target] |
207 |
else: |
208 |
args = ['clone', self.src + '/', target] |
209 |
@@ -73,7 +73,7 @@ class MercurialOverlay(OverlaySource): |
210 |
target = path([base, self.parent.name]) |
211 |
|
212 |
# hg pull -u SOURCE |
213 |
- if cfg_opts: |
214 |
+ if len(cfg_opts): |
215 |
args = ['pull', '-u', cfg_opts, self.src] |
216 |
else: |
217 |
args = ['pull', '-u', self.src] |
218 |
|
219 |
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py |
220 |
index 9486c38..9d2006b 100644 |
221 |
--- a/layman/overlays/overlay.py |
222 |
+++ b/layman/overlays/overlay.py |
223 |
@@ -143,7 +143,7 @@ class Overlay(object): |
224 |
return _class(parent=self, config=self.config, |
225 |
_location=_location, ignore=ignore, quiet=quiet) |
226 |
|
227 |
- if not _sources: |
228 |
+ if not len(_sources): |
229 |
raise Exception('Overlay "' + self.name + \ |
230 |
'" is missing a "source" entry!') |
231 |
|
232 |
|
233 |
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py |
234 |
index 76b289e..d282b35 100644 |
235 |
--- a/layman/overlays/rsync.py |
236 |
+++ b/layman/overlays/rsync.py |
237 |
@@ -69,7 +69,7 @@ class RsyncOverlay(OverlaySource): |
238 |
|
239 |
if quiet: |
240 |
args.append('-q') |
241 |
- if cfg_opts: |
242 |
+ if len(cfg_opts): |
243 |
args.append(cfg_opts) |
244 |
args.append(self.src + '/') |
245 |
args.append(target) |
246 |
|
247 |
diff --git a/layman/overlays/source.py b/layman/overlays/source.py |
248 |
index 458f627..a845266 100644 |
249 |
--- a/layman/overlays/source.py |
250 |
+++ b/layman/overlays/source.py |
251 |
@@ -126,10 +126,10 @@ class OverlaySource(object): |
252 |
env.update(env_updates) |
253 |
|
254 |
command_repr = ' '.join(args) |
255 |
- if env_updates: |
256 |
+ if env_updates is not None: |
257 |
command_repr = '%s %s' % (' '.join('%s=%s' % (k, v) for (k, v) |
258 |
in sorted(env_updates.items())), command_repr) |
259 |
- if cwd: |
260 |
+ if cwd is not None: |
261 |
command_repr = '( cd %s && %s )' % (cwd, command_repr) |
262 |
|
263 |
cmd = kwargs.get('cmd', '') |
264 |
@@ -176,7 +176,7 @@ class OverlaySource(object): |
265 |
return failed_sync |
266 |
# good to continue |
267 |
postsync_opt = self.config['%s_postsync' % self.__class__.type_key] |
268 |
- if postsync_opt: |
269 |
+ if len(postsync_opt): |
270 |
# repalce "%cwd=" while it's still a string' |
271 |
_opt = postsync_opt.replace('%cwd=', |
272 |
kwargs.get('cwd', '')).split() |
273 |
|
274 |
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py |
275 |
index e0eb632..6b124a3 100644 |
276 |
--- a/layman/overlays/svn.py |
277 |
+++ b/layman/overlays/svn.py |
278 |
@@ -58,7 +58,7 @@ class SvnOverlay(OverlaySource): |
279 |
args = ['co'] |
280 |
if quiet: |
281 |
args.append('-q') |
282 |
- if cfg_opts: |
283 |
+ if len(cfg_opts): |
284 |
args.append(cfg_opts) |
285 |
args.append(self.src + '/@') |
286 |
args.append(target) |
287 |
@@ -87,7 +87,7 @@ class SvnOverlay(OverlaySource): |
288 |
args = ['up'] |
289 |
if quiet: |
290 |
args.append('-q') |
291 |
- if cfg_opts: |
292 |
+ if len(cfg_opts): |
293 |
args.append(cfg_opts) |
294 |
args.append(target) |
295 |
|
296 |
|
297 |
diff --git a/layman/utils.py b/layman/utils.py |
298 |
index 03ddb45..e38ea7c 100644 |
299 |
--- a/layman/utils.py |
300 |
+++ b/layman/utils.py |
301 |
@@ -50,7 +50,7 @@ def decode_selection(selection): |
302 |
# fix None passed in, return an empty list |
303 |
selection = selection or [] |
304 |
enc = sys.getfilesystemencoding() |
305 |
- if enc: |
306 |
+ if enc is not None: |
307 |
return [i.decode(enc) for i in selection] |
308 |
return selection |