diff options
-rw-r--r-- | src/buildstream/element.py | 7 | ||||
-rw-r--r-- | src/buildstream/plugin.py | 39 | ||||
-rw-r--r-- | src/buildstream/plugins/sources/bzr.py | 2 | ||||
-rw-r--r-- | src/buildstream/plugins/sources/pip.py | 2 |
4 files changed, 3 insertions, 47 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py index 16c0b3967..bd42c45b8 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -502,10 +502,6 @@ class Element(Plugin): Raises: :class:`.LoadError`: When *member_name* is not found and no *default* was provided - This is essentially the same as :func:`~buildstream.plugin.Plugin.node_get_member` - except that it assumes the expected type is a string and will also perform variable - substitutions. - **Example:** .. code:: python @@ -534,9 +530,6 @@ class Element(Plugin): Raises: :class:`.LoadError` - This is essentially the same as :func:`~buildstream.plugin.Plugin.node_get_member` - except that it assumes the expected type is a list of strings and will also - perform variable substitutions. """ value = self.node_get_member(node, list, member_name) ret = [] diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py index 47b97441d..b2050e219 100644 --- a/src/buildstream/plugin.py +++ b/src/buildstream/plugin.py @@ -280,12 +280,7 @@ class Plugin(): Plugin implementors should implement this method to read configuration data and store it. - Plugins should use the :func:`Plugin.node_get_member() <buildstream.plugin.Plugin.node_get_member>` - method to fetch values from the passed `node`. This will ensure that a nice human readable error - message will be raised if the expected configuration is not found, indicating the filename, - line and column numbers. - - Further the :func:`Plugin.node_validate() <buildstream.plugin.Plugin.node_validate>` method + The :func:`Plugin.node_validate() <buildstream.plugin.Plugin.node_validate>` method should be used to ensure that the user has not specified keys in `node` which are unsupported by the plugin. @@ -385,38 +380,6 @@ class Plugin(): provenance = _yaml.node_get_provenance(node, key=member_name) return str(provenance) - def node_get_member(self, node, expected_type, member_name, default=_yaml._sentinel, *, allow_none=False): - """Fetch the value of a node member, raising an error if the value is - missing or incorrectly typed. - - Args: - node (Node): A dictionary loaded from YAML - expected_type (type): The expected type of the node member - member_name (str): The name of the member to fetch - default (expected_type): A value to return when *member_name* is not specified in *node* - allow_none (bool): Allow explicitly set None values in the YAML (*Since: 1.4*) - - Returns: - The value of *member_name* in *node*, otherwise *default* - - Raises: - :class:`.LoadError`: When *member_name* is not found and no *default* was provided - - Note: - Returned strings are stripped of leading and trailing whitespace - - **Example:** - - .. code:: python - - # Expect a string 'name' in 'node' - name = self.node_get_member(node, str, 'name') - - # Fetch an optional integer - level = self.node_get_member(node, int, 'level', -1) - """ - return _yaml.node_get(node, expected_type, member_name, default_value=default, allow_none=allow_none) - def node_set_member(self, node, key, value): """Set the value of a node member Args: diff --git a/src/buildstream/plugins/sources/bzr.py b/src/buildstream/plugins/sources/bzr.py index 082d11dec..28bea1415 100644 --- a/src/buildstream/plugins/sources/bzr.py +++ b/src/buildstream/plugins/sources/bzr.py @@ -93,7 +93,7 @@ class BzrSource(Source): return Consistency.RESOLVED def load_ref(self, node): - self.ref = self.node_get_member(node, str, 'ref', None) + self.ref = node.get_str('ref', None) def get_ref(self): return self.ref diff --git a/src/buildstream/plugins/sources/pip.py b/src/buildstream/plugins/sources/pip.py index db0537497..816b9e95b 100644 --- a/src/buildstream/plugins/sources/pip.py +++ b/src/buildstream/plugins/sources/pip.py @@ -150,7 +150,7 @@ class PipSource(Source): return self.ref def load_ref(self, node): - self.ref = self.node_get_member(node, str, 'ref', None) + self.ref = node.get_str('ref', None) def set_ref(self, ref, node): node['ref'] = self.ref = ref |