... |
... |
@@ -930,6 +930,38 @@ class Source(Plugin): |
930
|
930
|
# Local Private Methods #
|
931
|
931
|
#############################################################
|
932
|
932
|
|
|
933
|
+ # __clone_for_uri()
|
|
934
|
+ #
|
|
935
|
+ # Clone the source with an alternative URI setup for the alias
|
|
936
|
+ # which this source uses.
|
|
937
|
+ #
|
|
938
|
+ # This is used for iteration over source mirrors.
|
|
939
|
+ #
|
|
940
|
+ # Args:
|
|
941
|
+ # uri (str): The alternative URI for this source's alias
|
|
942
|
+ #
|
|
943
|
+ # Returns:
|
|
944
|
+ # (Source): A new clone of this Source, with the specified URI
|
|
945
|
+ # as the value of the alias this Source has marked as
|
|
946
|
+ # primary with either mark_download_url() or
|
|
947
|
+ # translate_url().
|
|
948
|
+ #
|
|
949
|
+ def __clone_for_uri(self, uri):
|
|
950
|
+ project = self._get_project()
|
|
951
|
+ context = self._get_context()
|
|
952
|
+ alias = self._get_alias()
|
|
953
|
+ source_kind = type(self)
|
|
954
|
+
|
|
955
|
+ clone = source_kind(context, project, self.__meta, alias_override=(alias, uri))
|
|
956
|
+
|
|
957
|
+ # Do the necessary post instantiation routines here
|
|
958
|
+ #
|
|
959
|
+ clone._preflight()
|
|
960
|
+ clone._load_ref()
|
|
961
|
+ clone._update_state()
|
|
962
|
+
|
|
963
|
+ return clone
|
|
964
|
+
|
933
|
965
|
# Tries to call fetch for every mirror, stopping once it succeeds
|
934
|
966
|
def __do_fetch(self, **kwargs):
|
935
|
967
|
project = self._get_project()
|
... |
... |
@@ -968,12 +1000,8 @@ class Source(Plugin): |
968
|
1000
|
self.fetch(**kwargs)
|
969
|
1001
|
return
|
970
|
1002
|
|
971
|
|
- context = self._get_context()
|
972
|
|
- source_kind = type(self)
|
973
|
1003
|
for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
|
974
|
|
- new_source = source_kind(context, project, self.__meta,
|
975
|
|
- alias_override=(alias, uri))
|
976
|
|
- new_source._preflight()
|
|
1004
|
+ new_source = self.__clone_for_uri(uri)
|
977
|
1005
|
try:
|
978
|
1006
|
new_source.fetch(**kwargs)
|
979
|
1007
|
# FIXME: Need to consider temporary vs. permanent failures,
|
... |
... |
@@ -1006,9 +1034,7 @@ class Source(Plugin): |
1006
|
1034
|
# NOTE: We are assuming here that tracking only requires substituting the
|
1007
|
1035
|
# first alias used
|
1008
|
1036
|
for uri in reversed(project.get_alias_uris(alias, first_pass=self.__first_pass)):
|
1009
|
|
- new_source = source_kind(context, project, self.__meta,
|
1010
|
|
- alias_override=(alias, uri))
|
1011
|
|
- new_source._preflight()
|
|
1037
|
+ new_source = self.__clone_for_uri(uri)
|
1012
|
1038
|
try:
|
1013
|
1039
|
ref = new_source.track(**kwargs)
|
1014
|
1040
|
# FIXME: Need to consider temporary vs. permanent failures,
|