summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-02 15:59:41 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-08 17:03:36 +0900
commit62da31935c90c93d41dd778a3b667490cd2287ea (patch)
tree3228c2a17e489002bedabc42cbf9869f96ac8d89
parent19d501fbf682fc231c73599cc029f43dad41a479 (diff)
downloadbuildstream-remove-variants.tar.gz
project.py: More consistent api for workspacesremove-variants
Renamed _workspaces() -> _list_workspaces(), and changed local cache of workspaces from __workspaces -> _workspaces. We only really use the double underscore when there is a concern for freeing up namespace for public subclassing.
-rw-r--r--buildstream/_frontend/main.py2
-rw-r--r--buildstream/_pipeline.py2
-rw-r--r--buildstream/project.py30
3 files changed, 17 insertions, 17 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index d21e4031f..27bc389bb 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -668,7 +668,7 @@ def workspace_list(app):
sys.exit(1)
workspaces = []
- for element_name, source_index, directory in project._workspaces():
+ for element_name, source_index, directory in project._list_workspaces():
workspace = {
'element': element_name,
'directory': directory,
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index d153335e1..32c00cf60 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -163,7 +163,7 @@ class Pipeline():
self.total_elements = len(list(self.dependencies(Scope.ALL)))
- for element_name, source, workspace in project._workspaces():
+ for element_name, source, workspace in project._list_workspaces():
element = self.target.search(Scope.ALL, element_name)
if element is None:
diff --git a/buildstream/project.py b/buildstream/project.py
index a2efe6ead..dcf1c1e1f 100644
--- a/buildstream/project.py
+++ b/buildstream/project.py
@@ -85,7 +85,7 @@ class Project():
self._environment = {} # The base sandbox environment
self._elements = {} # Element specific configurations
self._aliases = {} # Aliases dictionary
- self.__workspaces = {} # Workspaces
+ self._workspaces = {} # Workspaces
self._plugin_source_paths = [] # Paths to custom sources
self._plugin_element_paths = [] # Paths to custom plugins
self._cache_key = None
@@ -179,7 +179,7 @@ class Project():
self.artifact_push_port = _yaml.node_get(artifacts, int, 'push-port', default_value=22)
# Workspace configurations
- self.__workspaces = self._load_workspace_config()
+ self._workspaces = self._load_workspace_config()
# Version requirements
versions = _yaml.node_get(config, Mapping, 'required-versions')
@@ -228,16 +228,16 @@ class Project():
# Element configurations
self._elements = _yaml.node_get(config, Mapping, 'elements', default_value={})
- # _workspaces()
+ # _list_workspaces()
#
# Generator function to enumerate workspaces.
#
# Yields:
# A tuple in the following format: (element, source, path).
- def _workspaces(self):
- for element, _ in _yaml.node_items(self.__workspaces):
- for source, _ in _yaml.node_items(self.__workspaces[element]):
- yield (element, int(source), self.__workspaces[element][source])
+ def _list_workspaces(self):
+ for element, _ in _yaml.node_items(self._workspaces):
+ for source, _ in _yaml.node_items(self._workspaces[element]):
+ yield (element, int(source), self._workspaces[element][source])
# _get_workspace()
#
@@ -254,7 +254,7 @@ class Project():
#
def _get_workspace(self, element, index):
try:
- return self.__workspaces[element][index]
+ return self._workspaces[element][index]
except KeyError:
return None
@@ -269,10 +269,10 @@ class Project():
# path (str) - The path to set the workspace to
#
def _set_workspace(self, element, index, path):
- if element.name not in self.__workspaces:
- self.__workspaces[element.name] = {}
+ if element.name not in self._workspaces:
+ self._workspaces[element.name] = {}
- self.__workspaces[element.name][index] = path
+ self._workspaces[element.name][index] = path
element._set_source_workspace(index, path)
# _delete_workspace()
@@ -286,11 +286,11 @@ class Project():
# index (int) - The source index
#
def _delete_workspace(self, element, index):
- del self.__workspaces[element][index]
+ del self._workspaces[element][index]
# Contains a provenance object
- if len(self.__workspaces[element]) == 1:
- del self.__workspaces[element]
+ if len(self._workspaces[element]) == 1:
+ del self._workspaces[element]
# _load_workspace_config()
#
@@ -325,7 +325,7 @@ class Project():
# _set_workspace permanent
#
def _save_workspace_config(self):
- _yaml.dump(_yaml.node_sanitize(self.__workspaces),
+ _yaml.dump(_yaml.node_sanitize(self._workspaces),
os.path.join(self.directory, ".bst", "workspaces.yml"))
def _extract_plugin_paths(self, node, name):