xref: /OK3568_Linux_fs/yocto/poky/bitbake/lib/layerindexlib/plugin.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Copyright (C) 2016-2018 Wind River Systems, Inc.
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0-only
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun# The file contains:
6*4882a593Smuzhiyun#   LayerIndex exceptions
7*4882a593Smuzhiyun#   Plugin base class
8*4882a593Smuzhiyun#   Utility Functions for working on layerindex data
9*4882a593Smuzhiyun
10*4882a593Smuzhiyunimport logging
11*4882a593Smuzhiyun
12*4882a593Smuzhiyunlogger = logging.getLogger('BitBake.layerindexlib.plugin')
13*4882a593Smuzhiyun
14*4882a593Smuzhiyunclass LayerIndexPluginException(Exception):
15*4882a593Smuzhiyun    """LayerIndex Generic Exception"""
16*4882a593Smuzhiyun    def __init__(self, message):
17*4882a593Smuzhiyun         self.msg = message
18*4882a593Smuzhiyun         Exception.__init__(self, message)
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun    def __str__(self):
21*4882a593Smuzhiyun         return self.msg
22*4882a593Smuzhiyun
23*4882a593Smuzhiyunclass LayerIndexPluginUrlError(LayerIndexPluginException):
24*4882a593Smuzhiyun    """Exception raised when a plugin does not support a given URL type"""
25*4882a593Smuzhiyun    def __init__(self, plugin, url):
26*4882a593Smuzhiyun        msg = "%s does not support %s:" % (plugin, url)
27*4882a593Smuzhiyun        self.plugin = plugin
28*4882a593Smuzhiyun        self.url = url
29*4882a593Smuzhiyun        LayerIndexPluginException.__init__(self, msg)
30*4882a593Smuzhiyun
31*4882a593Smuzhiyunclass IndexPlugin():
32*4882a593Smuzhiyun    def __init__(self):
33*4882a593Smuzhiyun        self.type = None
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun    def init(self, layerindex):
36*4882a593Smuzhiyun        self.layerindex = layerindex
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun    def plugin_type(self):
39*4882a593Smuzhiyun        return self.type
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun    def load_index(self, uri):
42*4882a593Smuzhiyun        raise NotImplementedError('load_index is not implemented')
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun    def store_index(self, uri, index):
45*4882a593Smuzhiyun        raise NotImplementedError('store_index is not implemented')
46*4882a593Smuzhiyun
47