From 3341948a60f493163605b1e311c412b7d5df09e5 Mon Sep 17 00:00:00 2001 From: Jim MacArthur Date: Sun, 29 Jul 2018 20:51:44 +0100 Subject: Move KeyStrength enum out to element_enums.py --- buildstream/__init__.py | 3 +- buildstream/_artifactcache/artifactcache.py | 2 +- buildstream/element.py | 39 ++---------------- buildstream/element_enums.py | 61 +++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 38 deletions(-) create mode 100644 buildstream/element_enums.py 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 . +# +# Authors: +# Tristan Van Berkom +# Jim MacArthur + +""" +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. + """ -- cgit v1.2.1