plugin.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright (C) 2016-2018 Wind River Systems, Inc.
  2. #
  3. # SPDX-License-Identifier: GPL-2.0-only
  4. #
  5. # The file contains:
  6. # LayerIndex exceptions
  7. # Plugin base class
  8. # Utility Functions for working on layerindex data
  9. import logging
  10. logger = logging.getLogger('BitBake.layerindexlib.plugin')
  11. class LayerIndexPluginException(Exception):
  12. """LayerIndex Generic Exception"""
  13. def __init__(self, message):
  14. self.msg = message
  15. Exception.__init__(self, message)
  16. def __str__(self):
  17. return self.msg
  18. class LayerIndexPluginUrlError(LayerIndexPluginException):
  19. """Exception raised when a plugin does not support a given URL type"""
  20. def __init__(self, plugin, url):
  21. msg = "%s does not support %s:" % (plugin, url)
  22. self.plugin = plugin
  23. self.url = url
  24. LayerIndexPluginException.__init__(self, msg)
  25. class IndexPlugin():
  26. def __init__(self):
  27. self.type = None
  28. def init(self, layerindex):
  29. self.layerindex = layerindex
  30. def plugin_type(self):
  31. return self.type
  32. def load_index(self, uri):
  33. raise NotImplementedError('load_index is not implemented')
  34. def store_index(self, uri, index):
  35. raise NotImplementedError('store_index is not implemented')