From 2eccea85dc231db70cec6b2598bbfdd78330667d Mon Sep 17 00:00:00 2001 From: Tristan van Berkom Date: Thu, 11 Jun 2020 18:59:50 +0900 Subject: _project.py: Reorganize methods Add some comments clearly separating public and private methods, and moving the _validate_node() private method into the private section, renaming it _validate_toplevel_node() for better clarity. --- src/buildstream/_project.py | 77 +++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py index 492330e96..3006e2976 100644 --- a/src/buildstream/_project.py +++ b/src/buildstream/_project.py @@ -179,6 +179,10 @@ class Project: def source_overrides(self): return self.config.source_overrides + ######################################################## + # Public Methods # + ######################################################## + # translate_url(): # # Translates the given url which may be specified with an alias @@ -320,35 +324,6 @@ class Project: return path_str - def _validate_node(self, node): - node.validate_keys( - [ - "min-version", - "element-path", - "variables", - "environment", - "environment-nocache", - "split-rules", - "elements", - "plugins", - "aliases", - "name", - "defaults", - "artifacts", - "options", - "fail-on-overlap", - "shell", - "fatal-warnings", - "ref-storage", - "sandbox", - "mirrors", - "remote-execution", - "sources", - "source-caches", - "(@)", - ] - ) - # create_element() # # Instantiate and return an element @@ -559,6 +534,46 @@ class Project: return tuple(default_targets) + ######################################################## + # Private Methods # + ######################################################## + + # _validate_toplevel_node() + # + # Validates the toplevel project.conf keys + # + # Args: + # node (MappingNode): The toplevel project.conf node + # + def _validate_toplevel_node(self, node): + node.validate_keys( + [ + "min-version", + "element-path", + "variables", + "environment", + "environment-nocache", + "split-rules", + "elements", + "plugins", + "aliases", + "name", + "defaults", + "artifacts", + "options", + "fail-on-overlap", + "shell", + "fatal-warnings", + "ref-storage", + "sandbox", + "mirrors", + "remote-execution", + "sources", + "source-caches", + "(@)", + ] + ) + # _validate_version() # # Asserts that we have a BuildStream installation which is recent @@ -655,7 +670,7 @@ class Project: # Assert project's minimum required version early, before validating toplevel keys self._validate_version(pre_config_node) - self._validate_node(pre_config_node) + self._validate_toplevel_node(pre_config_node) # The project name, element path and option declarations # are constant and cannot be overridden by option conditional statements @@ -715,7 +730,7 @@ class Project: self._load_pass(config, self.config) - self._validate_node(config) + self._validate_toplevel_node(config) # # Now all YAML composition is done, from here on we just load -- cgit v1.2.1