1 |
On Sat, 18 Jan 2014 19:07:45 -0800 |
2 |
"W. Trevor King" <wking@×××××××.us> wrote: |
3 |
|
4 |
> [...SNIP...] |
5 |
> + v = |
6 |
> int(settings.get("PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS", |
7 |
> + default)) |
8 |
> + except (ValueError, OverflowError): |
9 |
> + writemsg(_("!!! Variable |
10 |
> PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS" |
11 |
> + " contains non-integer value: '%s'\n") % \ |
12 |
> + |
13 |
> settings["PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"], |
14 |
> + noiselevel=-1) |
15 |
> + writemsg(_("!!! Using |
16 |
> PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS " |
17 |
> + "default value: %s\n") % default, |
18 |
> + noiselevel=-1) |
19 |
> + v = default |
20 |
> + if v < 1: |
21 |
> + writemsg(_("!!! Variable |
22 |
> PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS" |
23 |
> + " contains value less than 1: '%s'\n") % v, |
24 |
> noiselevel=-1) |
25 |
> + writemsg(_("!!! Using |
26 |
> PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS " |
27 |
> [...SNIP...] |
28 |
|
29 |
The code screams PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS to me which makes |
30 |
it hard to read, I would suggest assigning it to a variable in advance |
31 |
as to not have to repeat it this often. Some code snippets for ideas: |
32 |
|
33 |
key = "PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS" |
34 |
|
35 |
v = int(settings.get(key), default) |
36 |
|
37 |
"!!! Variable %s contains non-integer value: '%s" % (key, ...) |
38 |
|
39 |
If needed, add a word to key to make the variable name slightly more |
40 |
meaningful; but avoid the full length if possible. eg. try_mirrors_key |
41 |
|
42 |
-- |
43 |
With kind regards, |
44 |
|
45 |
Tom Wijsman (TomWij) |
46 |
Gentoo Developer |
47 |
|
48 |
E-mail address : TomWij@g.o |
49 |
GPG Public Key : 6D34E57D |
50 |
GPG Fingerprint : C165 AF18 AB4C 400B C3D2 ABF0 95B2 1FCD 6D34 E57D |