pym/portage/package/ebuild/fetch.py: Factor out _get_uris fetch-refactor-v2
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 21:38:58 +0000 (13:38 -0800)
commit11f339ff2422304916eee3d9b0eb510baa535e6b
tree50118054b98e37189160438ae7c9a416e0680da3
parente38cb223682226bb6b520cbc66928a96c6c9a1cf
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