Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | # Copyright (C) 2016-2018 Wind River Systems, Inc. |
| 2 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 4 | # |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5 | # The file contains: |
| 6 | # LayerIndex exceptions |
| 7 | # Plugin base class |
| 8 | # Utility Functions for working on layerindex data |
| 9 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 10 | import logging |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 11 | |
| 12 | logger = logging.getLogger('BitBake.layerindexlib.plugin') |
| 13 | |
| 14 | class 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 | |
| 23 | class 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 | |
| 31 | class 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 | |