summaryrefslogtreecommitdiff
path: root/src/buildstream/_project.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildstream/_project.py')
-rw-r--r--src/buildstream/_project.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index fa02143e1..6fed36eca 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -34,6 +34,7 @@ from ._artifactcache import ArtifactCache
from ._sourcecache import SourceCache
from .node import ScalarNode, SequenceNode, _assert_symbol_name
from .sandbox import SandboxRemote
+from .types import FastEnum
from ._elementfactory import ElementFactory
from ._sourcefactory import SourceFactory
from .types import CoreWarnings
@@ -50,6 +51,12 @@ from ._workspaces import WORKSPACE_PROJECT_FILE
_PROJECT_CONF_FILE = 'project.conf'
+class PluginOrigins(FastEnum):
+ CORE = "core"
+ LOCAL = "local"
+ PIP = "pip"
+
+
# HostMount()
#
# A simple object describing the behavior of
@@ -869,16 +876,8 @@ class Project():
'origin', 'sources', 'elements',
'package-name', 'path',
]
- allowed_origins = ['core', 'local', 'pip']
origin.validate_keys(allowed_origin_fields)
- origin_value = origin.get_str('origin')
- if origin_value not in allowed_origins:
- raise LoadError(
- LoadErrorReason.INVALID_YAML,
- "Origin '{}' is not one of the allowed types"
- .format(origin_value))
-
# Store source versions for checking later
source_versions = origin.get_mapping('sources', default={})
for key in source_versions.keys():
@@ -899,7 +898,9 @@ class Project():
# Store the origins if they're not 'core'.
# core elements are loaded by default, so storing is unnecessary.
- if origin.get_str('origin') != 'core':
+ origin_value = origin.get_enum('origin', PluginOrigins)
+
+ if origin_value != PluginOrigins.CORE:
self._store_origin(origin, 'sources', plugin_source_origins)
self._store_origin(origin, 'elements', plugin_element_origins)
@@ -939,7 +940,7 @@ class Project():
if group in origin_node:
del origin_node[group]
- if origin_node.get_str('origin') == 'local':
+ if origin_node.get_enum('origin', PluginOrigins) == PluginOrigins.LOCAL:
path = self.get_path_from_node(origin.get_scalar('path'),
check_is_dir=True)
# paths are passed in relative to the project, but must be absolute