blob: cadda36c748841a1690a97e0b041df715904db28 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001# Copyright (C) 2016-2018 Wind River Systems, Inc.
2#
Brad Bishopc342db32019-05-15 21:57:59 -04003# SPDX-License-Identifier: GPL-2.0-only
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08004#
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08005# The file contains:
6# LayerIndex exceptions
7# Plugin base class
8# Utility Functions for working on layerindex data
9
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080010import logging
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080011
12logger = logging.getLogger('BitBake.layerindexlib.plugin')
13
14class LayerIndexPluginException(Exception):
15 """LayerIndex Generic Exception"""
16 def __init__(self, message):
17 self.msg = message
18 Exception.__init__(self, message)
19
20 def __str__(self):
21 return self.msg
22
23class LayerIndexPluginUrlError(LayerIndexPluginException):
24 """Exception raised when a plugin does not support a given URL type"""
25 def __init__(self, plugin, url):
26 msg = "%s does not support %s:" % (plugin, url)
27 self.plugin = plugin
28 self.url = url
29 LayerIndexPluginException.__init__(self, msg)
30
31class IndexPlugin():
32 def __init__(self):
33 self.type = None
34
35 def init(self, layerindex):
36 self.layerindex = layerindex
37
38 def plugin_type(self):
39 return self.type
40
41 def load_index(self, uri):
42 raise NotImplementedError('load_index is not implemented')
43
44 def store_index(self, uri, index):
45 raise NotImplementedError('store_index is not implemented')
46