pym/portage/package/ebuild/fetch.py: Factor out _get_uris fetch-refactor-v1
authorW. Trevor King <wking@tremily.us>
Sun, 19 Jan 2014 02:29:15 +0000 (18:29 -0800)
committerW. Trevor King <wking@tremily.us>
Sun, 19 Jan 2014 02:46:42 +0000 (18:46 -0800)
commit43632318589c05c4959f9dcf0bb39a6b0b50e8b8
tree302bdfe91901b64610757ebc676354f99df249e2
parent8db147529a1958a6c86087a521e33c019e619dec
pym/portage/package/ebuild/fetch.py: Factor out _get_uris

The current fetch() function is quite long, which makes it hard to
know what I can change without adverse side effects.  By pulling this
logic out of the main function, we get clearer logic in fetch() and
more explicit input for the config extraction.

This block was especially complicated, so I also created the helper
functions _get_file_uri_tuples and _expand_mirror.  I'd prefer if
_expand_mirror iterated through URIs instead of (group, URI) tuples,
but we need a distinct marker for third-party URIs to build
third_party_mirror_uris which is used to build primaryuri_dict which
is used way down in fetch():

  if checksum_failure_count == \
      checksum_failure_primaryuri:
      # Switch to "primaryuri" mode in order
      # to increase the probablility of
      # of success.
      primaryuris = \
          primaryuri_dict.get(myfile)
          if primaryuris:
              uri_list.extend(
                  reversed(primaryuris))

I don't know if this is useful enough to motivate the uglier
_expandmirror return values, but I'll kick that can down the road for
now.
pym/portage/package/ebuild/fetch.py