summaryrefslogtreecommitdiff
path: root/buildstream/plugin.py
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 /buildstream/plugin.py
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.
Diffstat (limited to 'buildstream/plugin.py')
-rw-r--r--buildstream/plugin.py60
1 files changed, 19 insertions, 41 deletions
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