public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* Re: [gentoo-portage-dev] [PATCH 1/3] pym/portage/package/ebuild/fetch.py: Factor out _get_checksum_failure_max_tries
  @ 2014-01-20  1:26 99%   ` Tom Wijsman
  0 siblings, 0 replies; 1+ results
From: Tom Wijsman @ 2014-01-20  1:26 UTC (permalink / raw
  To: wking; +Cc: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]

On Sat, 18 Jan 2014 19:07:45 -0800
"W. Trevor King" <wking@tremily.us> wrote:

> [...SNIP...]
> +		v =
> int(settings.get("PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS",
> +			default))
> +	except (ValueError, OverflowError):
> +		writemsg(_("!!! Variable
> PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"
> +			" contains non-integer value: '%s'\n") % \
> +
> settings["PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"],
> +			noiselevel=-1)
> +		writemsg(_("!!! Using
> PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS "
> +			"default value: %s\n") % default,
> +			noiselevel=-1)
> +		v = default
> +	if v < 1:
> +		writemsg(_("!!! Variable
> PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"
> +			" contains value less than 1: '%s'\n") % v,
> noiselevel=-1)
> +		writemsg(_("!!! Using
> PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS "
> [...SNIP...]

The code screams PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS to me which makes
it hard to read, I would suggest assigning it to a variable in advance
as to not have to repeat it this often. Some code snippets for ideas:

    key = "PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS"

    v = int(settings.get(key), default)

    "!!! Variable %s contains non-integer value: '%s" % (key, ...)

If needed, add a word to key to make the variable name slightly more
meaningful; but avoid the full length if possible. eg. try_mirrors_key

-- 
With kind regards,

Tom Wijsman (TomWij)
Gentoo Developer

E-mail address  : TomWij@gentoo.org
GPG Public Key  : 6D34E57D
GPG Fingerprint : C165 AF18 AB4C 400B C3D2  ABF0 95B2 1FCD 6D34 E57D

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2014-01-19  3:07     [gentoo-portage-dev] [PATCH 0/3] Initial fetch() refactoring W. Trevor King
2014-01-19  3:07     ` [gentoo-portage-dev] [PATCH 1/3] pym/portage/package/ebuild/fetch.py: Factor out _get_checksum_failure_max_tries W. Trevor King
2014-01-20  1:26 99%   ` Tom Wijsman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox