summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-07-29 20:51:44 +0100
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-08-15 15:33:05 +0100
commit3341948a60f493163605b1e311c412b7d5df09e5 (patch)
treeafc4eb67304528f824d784da104e177d3599a44e
parentb84218a42109bdf7a5b390b2db96926e28c592d1 (diff)
downloadbuildstream-3341948a60f493163605b1e311c412b7d5df09e5.tar.gz
Move KeyStrength enum out to element_enums.py
-rw-r--r--buildstream/__init__.py3
-rw-r--r--buildstream/_artifactcache/artifactcache.py2
-rw-r--r--buildstream/element.py39
-rw-r--r--buildstream/element_enums.py61
4 files changed, 67 insertions, 38 deletions
diff --git a/buildstream/__init__.py b/buildstream/__init__.py
index 895adc60f..0f6efb0da 100644
--- a/buildstream/__init__.py
+++ b/buildstream/__init__.py
@@ -30,6 +30,7 @@ if "_BST_COMPLETION" not in os.environ:
from .sandbox import Sandbox, SandboxFlags
from .plugin import Plugin
from .source import Source, SourceError, Consistency, SourceFetcher
- from .element import Element, ElementError, Scope
+ from .element import Element, ElementError
+ from .element_enums import Scope
from .buildelement import BuildElement
from .scriptelement import ScriptElement
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index a7af94719..d98c291f9 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -21,7 +21,7 @@ import os
import string
from collections import Mapping, namedtuple
-from ..element import _KeyStrength
+from ..element_enums import _KeyStrength
from .._exceptions import ArtifactError, ImplError, LoadError, LoadErrorReason
from .._message import Message, MessageType
from .. import utils
diff --git a/buildstream/element.py b/buildstream/element.py
index bb205c777..40cac47cd 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -78,7 +78,6 @@ import stat
import copy
from collections import Mapping, OrderedDict
from contextlib import contextmanager
-from enum import Enum
import tempfile
import shutil
@@ -98,41 +97,9 @@ from .plugin import CoreWarnings
from .sandbox._config import SandboxConfig
from .storage.directory import Directory
-from .storage._filebaseddirectory import FileBasedDirectory, VirtualDirectoryError
-
-
-# _KeyStrength():
-#
-# Strength of cache key
-#
-class _KeyStrength(Enum):
-
- # Includes strong cache keys of all build dependencies and their
- # runtime dependencies.
- STRONG = 1
-
- # Includes names of direct build dependencies but does not include
- # cache keys of dependencies.
- WEAK = 2
-
-
-class Scope(Enum):
- """Types of scope for a given element"""
-
- ALL = 1
- """All elements which the given element depends on, following
- all elements required for building. Including the element itself.
- """
-
- BUILD = 2
- """All elements required for building the element, including their
- respective run dependencies. Not including the given element itself.
- """
-
- RUN = 3
- """All elements required for running the element. Including the element
- itself.
- """
+from .storage._filebaseddirectory import FileBasedDirectory
+from .storage.directory import VirtualDirectoryError
+from .element_enums import _KeyStrength, Scope
class ElementError(BstError):
diff --git a/buildstream/element_enums.py b/buildstream/element_enums.py
new file mode 100644
index 000000000..2f2fb54d2
--- /dev/null
+++ b/buildstream/element_enums.py
@@ -0,0 +1,61 @@
+#
+# Copyright (C) 2018 Bloomberg LP
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+#
+# Authors:
+# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
+# Jim MacArthur <jim.macarthur@codethink.co.uk>
+
+"""
+Element - Globally visible enumerations
+=======================================
+
+"""
+
+from enum import Enum
+
+
+# _KeyStrength():
+#
+# Strength of cache key
+#
+class _KeyStrength(Enum):
+
+ # Includes strong cache keys of all build dependencies and their
+ # runtime dependencies.
+ STRONG = 1
+
+ # Includes names of direct build dependencies but does not include
+ # cache keys of dependencies.
+ WEAK = 2
+
+
+class Scope(Enum):
+ """Types of scope for a given element"""
+
+ ALL = 1
+ """All elements which the given element depends on, following
+ all elements required for building. Including the element itself.
+ """
+
+ BUILD = 2
+ """All elements required for building the element, including their
+ respective run dependencies. Not including the given element itself.
+ """
+
+ RUN = 3
+ """All elements required for running the element. Including the element
+ itself.
+ """