summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-04 16:15:14 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-06 16:35:59 +0900
commit03028c7f3d23b51879e362700e74f14a40755c3c (patch)
tree4639b4ee8358460459710137a0fbbe7561359275
parent4688b2c90e33cb801d4e23a6ed80060d517d697f (diff)
downloadbuildstream-03028c7f3d23b51879e362700e74f14a40755c3c.tar.gz
types.py: Moving CoreWarnings to the types.py module
This also ensures it is exposed via the main buildstream __init__.py file, fixes the imports of CoreWarnings, and adjusts the documentation links to point to the right place.
-rw-r--r--buildstream/__init__.py2
-rw-r--r--buildstream/_loader/loader.py2
-rw-r--r--buildstream/_project.py2
-rw-r--r--buildstream/element.py3
-rw-r--r--buildstream/plugin.py60
-rw-r--r--buildstream/plugins/sources/git.py3
-rw-r--r--buildstream/types.py25
-rw-r--r--doc/source/format_project.rst2
8 files changed, 50 insertions, 49 deletions
diff --git a/buildstream/__init__.py b/buildstream/__init__.py
index fc09f2812..baacc480b 100644
--- a/buildstream/__init__.py
+++ b/buildstream/__init__.py
@@ -28,7 +28,7 @@ if "_BST_COMPLETION" not in os.environ:
from .utils import UtilError, ProgramNotFoundError
from .sandbox import Sandbox, SandboxFlags, SandboxCommandError
- from .types import Scope, Consistency
+ from .types import Scope, Consistency, CoreWarnings
from .plugin import Plugin
from .source import Source, SourceError, SourceFetcher
from .element import Element, ElementError
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py
index a172a10c8..0de0e2b9c 100644
--- a/buildstream/_loader/loader.py
+++ b/buildstream/_loader/loader.py
@@ -36,7 +36,7 @@ from .types import Symbol, Dependency
from .loadelement import LoadElement
from . import MetaElement
from . import MetaSource
-from ..plugin import CoreWarnings
+from ..types import CoreWarnings
from .._message import Message, MessageType
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 52408b7e5..386036488 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -33,7 +33,7 @@ from ._artifactcache import ArtifactCache
from .sandbox import SandboxRemote
from ._elementfactory import ElementFactory
from ._sourcefactory import SourceFactory
-from .plugin import CoreWarnings
+from .types import CoreWarnings
from ._projectrefs import ProjectRefs, ProjectRefStorage
from ._versions import BST_FORMAT_VERSION
from ._loader import Loader
diff --git a/buildstream/element.py b/buildstream/element.py
index 27677b054..ed279458c 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -96,10 +96,9 @@ from . import _cachekey
from . import _signals
from . import _site
from ._platform import Platform
-from .plugin import CoreWarnings
from .sandbox._config import SandboxConfig
from .sandbox._sandboxremote import SandboxRemote
-from .types import _KeyStrength
+from .types import _KeyStrength, CoreWarnings
from .storage.directory import Directory
from .storage._filebaseddirectory import FileBasedDirectory
diff --git a/buildstream/plugin.py b/buildstream/plugin.py
index 37dd78cc8..1e8dd4b9f 100644
--- a/buildstream/plugin.py
+++ b/buildstream/plugin.py
@@ -119,6 +119,7 @@ from . import _yaml
from . import utils
from ._exceptions import PluginError, ImplError
from ._message import Message, MessageType
+from .types import CoreWarnings
class Plugin():
@@ -766,38 +767,6 @@ class Plugin():
return self.name
-class CoreWarnings():
- """CoreWarnings()
-
- Some common warnings which are raised by core functionalities within BuildStream are found in this class.
- """
-
- OVERLAPS = "overlaps"
- """
- This warning will be produced when buildstream detects an overlap on an element
- which is not whitelisted. See :ref:`Overlap Whitelist <public_overlap_whitelist>`
- """
-
- REF_NOT_IN_TRACK = "ref-not-in-track"
- """
- This warning will be produced when a source is configured with a reference
- which is found to be invalid based on the configured track
- """
-
- BAD_ELEMENT_SUFFIX = "bad-element-suffix"
- """
- This warning will be produced when an element whose name does not end in .bst
- is referenced either on the command line or by another element
- """
-
-
-__CORE_WARNINGS = [
- value
- for name, value in CoreWarnings.__dict__.items()
- if not name.startswith("__")
-]
-
-
# Hold on to a lookup table by counter of all instantiated plugins.
# We use this to send the id back from child processes so we can lookup
# corresponding element/source in the master process.
@@ -828,6 +797,24 @@ def _plugin_lookup(unique_id):
return __PLUGINS_TABLE[unique_id]
+# No need for unregister, WeakValueDictionary() will remove entries
+# in itself when the referenced plugins are garbage collected.
+def _plugin_register(plugin):
+ global __PLUGINS_UNIQUE_ID # pylint: disable=global-statement
+ __PLUGINS_UNIQUE_ID += 1
+ __PLUGINS_TABLE[__PLUGINS_UNIQUE_ID] = plugin
+ return __PLUGINS_UNIQUE_ID
+
+
+# A local table for _prefix_warning()
+#
+__CORE_WARNINGS = [
+ value
+ for name, value in CoreWarnings.__dict__.items()
+ if not name.startswith("__")
+]
+
+
# _prefix_warning():
#
# Prefix a warning with the plugin kind. CoreWarnings are not prefixed.
@@ -843,12 +830,3 @@ def _prefix_warning(plugin, warning):
if any((warning is core_warning for core_warning in __CORE_WARNINGS)):
return warning
return "{}:{}".format(plugin.get_kind(), warning)
-
-
-# No need for unregister, WeakValueDictionary() will remove entries
-# in itself when the referenced plugins are garbage collected.
-def _plugin_register(plugin):
- global __PLUGINS_UNIQUE_ID # pylint: disable=global-statement
- __PLUGINS_UNIQUE_ID += 1
- __PLUGINS_TABLE[__PLUGINS_UNIQUE_ID] = plugin
- return __PLUGINS_UNIQUE_ID
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index e3dded1d4..112b72827 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -149,9 +149,8 @@ from tempfile import TemporaryFile
from configparser import RawConfigParser
-from buildstream import Source, SourceError, Consistency, SourceFetcher
+from buildstream import Source, SourceError, Consistency, SourceFetcher, CoreWarnings
from buildstream import utils
-from buildstream.plugin import CoreWarnings
from buildstream.utils import move_atomic, DirectoryExistsError
GIT_MODULES = '.gitmodules'
diff --git a/buildstream/types.py b/buildstream/types.py
index 3eb4a9110..5e6265b4e 100644
--- a/buildstream/types.py
+++ b/buildstream/types.py
@@ -81,6 +81,31 @@ class Consistency():
"""
+class CoreWarnings():
+ """CoreWarnings()
+
+ Some common warnings which are raised by core functionalities within BuildStream are found in this class.
+ """
+
+ OVERLAPS = "overlaps"
+ """
+ This warning will be produced when buildstream detects an overlap on an element
+ which is not whitelisted. See :ref:`Overlap Whitelist <public_overlap_whitelist>`
+ """
+
+ REF_NOT_IN_TRACK = "ref-not-in-track"
+ """
+ This warning will be produced when a source is configured with a reference
+ which is found to be invalid based on the configured track
+ """
+
+ BAD_ELEMENT_SUFFIX = "bad-element-suffix"
+ """
+ This warning will be produced when an element whose name does not end in .bst
+ is referenced either on the command line or by another element
+ """
+
+
# _KeyStrength():
#
# Strength of cache key
diff --git a/doc/source/format_project.rst b/doc/source/format_project.rst
index a85bf6470..4024cea19 100644
--- a/doc/source/format_project.rst
+++ b/doc/source/format_project.rst
@@ -143,7 +143,7 @@ Individual warnings can be configured as fatal by setting ``fatal-warnings`` to
- ref-not-in-track
- <plugin>:<warning>
-BuildStream provides a collection of :class:`Core Warnings <buildstream.plugin.CoreWarnings>` which may be raised
+BuildStream provides a collection of :class:`Core Warnings <buildstream.types.CoreWarnings>` which may be raised
by a variety of plugins. Other configurable warnings are plugin specific and should be noted within their individual documentation.
.. note::