diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-03-08 17:26:00 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-25 11:46:44 +0000 |
commit | f5971afc4c5558453103e54f0e3ac4c18e5bafc4 (patch) | |
tree | b50a40af6291d47ee8b17b3ba5332bf2281c6a47 /buildstream | |
parent | 1ab80a03e6611cbc0e7480ce442717ca07f1a0ab (diff) | |
download | buildstream-f5971afc4c5558453103e54f0e3ac4c18e5bafc4.tar.gz |
_basecache.py: Moves has remote methods
Move both `has_push_remotes` and `has_fetch_remotes` from
`ArtifactCache`.
Part of #440
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_artifactcache.py | 42 | ||||
-rw-r--r-- | buildstream/_basecache.py | 42 | ||||
-rw-r--r-- | buildstream/element.py | 4 |
3 files changed, 44 insertions, 44 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py index f97da4661..4af6f132c 100644 --- a/buildstream/_artifactcache.py +++ b/buildstream/_artifactcache.py @@ -263,48 +263,6 @@ class ArtifactCache(BaseCache): return self.cas.diff(ref_a, ref_b, subdir=subdir) - # has_fetch_remotes(): - # - # Check whether any remote repositories are available for fetching. - # - # Args: - # element (Element): The Element to check - # - # Returns: True if any remote repositories are configured, False otherwise - # - def has_fetch_remotes(self, *, element=None): - if not self._has_fetch_remotes: - # No project has fetch remotes - return False - elif element is None: - # At least one (sub)project has fetch remotes - return True - else: - # Check whether the specified element's project has fetch remotes - remotes_for_project = self._remotes[element._get_project()] - return bool(remotes_for_project) - - # has_push_remotes(): - # - # Check whether any remote repositories are available for pushing. - # - # Args: - # element (Element): The Element to check - # - # Returns: True if any remote repository is configured, False otherwise - # - def has_push_remotes(self, *, element=None): - if not self._has_push_remotes: - # No project has push remotes - return False - elif element is None: - # At least one (sub)project has push remotes - return True - else: - # Check whether the specified element's project has push remotes - remotes_for_project = self._remotes[element._get_project()] - return any(remote.spec.push for remote in remotes_for_project) - # push(): # # Push committed artifact to remote repository. diff --git a/buildstream/_basecache.py b/buildstream/_basecache.py index a8c58e48f..696cbf9c1 100644 --- a/buildstream/_basecache.py +++ b/buildstream/_basecache.py @@ -190,6 +190,48 @@ class BaseCache(): self._remotes[project] = project_remotes + # has_fetch_remotes(): + # + # Check whether any remote repositories are available for fetching. + # + # Args: + # plugin (Plugin): The Plugin to check + # + # Returns: True if any remote repositories are configured, False otherwise + # + def has_fetch_remotes(self, *, plugin=None): + if not self._has_fetch_remotes: + # No project has fetch remotes + return False + elif plugin is None: + # At least one (sub)project has fetch remotes + return True + else: + # Check whether the specified element's project has fetch remotes + remotes_for_project = self._remotes[plugin._get_project()] + return bool(remotes_for_project) + + # has_push_remotes(): + # + # Check whether any remote repositories are available for pushing. + # + # Args: + # element (Element): The Element to check + # + # Returns: True if any remote repository is configured, False otherwise + # + def has_push_remotes(self, *, plugin=None): + if not self._has_push_remotes: + # No project has push remotes + return False + elif plugin is None: + # At least one (sub)project has push remotes + return True + else: + # Check whether the specified element's project has push remotes + remotes_for_project = self._remotes[plugin._get_project()] + return any(remote.spec.push for remote in remotes_for_project) + ################################################ # Local Private Methods # ################################################ diff --git a/buildstream/element.py b/buildstream/element.py index cb04a9c15..08cdac724 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -1810,7 +1810,7 @@ class Element(Plugin): # Pull is pending if artifact remote server available # and pull has not been attempted yet - return self.__artifacts.has_fetch_remotes(element=self) and not self.__pull_done + return self.__artifacts.has_fetch_remotes(plugin=self) and not self.__pull_done # _pull_done() # @@ -1863,7 +1863,7 @@ class Element(Plugin): # (bool): True if this element does not need a push job to be created # def _skip_push(self): - if not self.__artifacts.has_push_remotes(element=self): + if not self.__artifacts.has_push_remotes(plugin=self): # No push remotes for this element's project return True |