From: W. Trevor King Date: Mon, 20 Jan 2014 03:15:57 +0000 (-0800) Subject: ebuild: fetch: Flatten conditionals in _get_fetch_resume_size X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f61bdf37042b4986a723021779751eb00d785121;p=portage.git ebuild: fetch: Flatten conditionals in _get_fetch_resume_size Make this easier to read by avoiding nested conditionals [1]. [1]: http://article.gmane.org/gmane.linux.gentoo.portage.devel/4058 Reported-by: Tom Wijsman --- diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py index 0093a6e3b..2bf88d8b1 100644 --- a/pym/portage/package/ebuild/fetch.py +++ b/pym/portage/package/ebuild/fetch.py @@ -276,24 +276,22 @@ def _get_checksum_failure_max_tries(settings, default=5): def _get_fetch_resume_size(settings, default='350K'): key = 'PORTAGE_FETCH_RESUME_MIN_SIZE' - v = settings.get(key) + v = settings.get(key, default) if v is not None: v = "".join(v.split()) - if not v: - # If it's empty, silently use the default. - v = default - match = _fetch_resume_size_re.match(v) - if (match is None or - match.group(2).upper() not in _size_suffix_map): - writemsg(_("!!! Variable %s contains an " - "unrecognized format: '%s'\n") - % (key, settings[key]), - noiselevel=-1) - writemsg(_("!!! Using %s default value: %s\n") - % (key, default), - noiselevel=-1) - v = None - if v is None: + if not v: + # If it's empty, silently use the default. + v = default + match = _fetch_resume_size_re.match(v) + if (match is None or + match.group(2).upper() not in _size_suffix_map): + writemsg(_("!!! Variable %s contains " + "an unrecognized format: '%s'\n") + % (key, settings[key]), + noiselevel=-1) + writemsg(_("!!! Using %s default value: %s\n") + % (key, default), + noiselevel=-1) v = default match = _fetch_resume_size_re.match(v) v = int(match.group(1)) * \