common.py 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. import argparse
  2. import logging
  3. import os
  4. logger = logging.getLogger('bitbake-layers')
  5. class LayerPlugin():
  6. def __init__(self):
  7. self.tinfoil = None
  8. self.bblayers = []
  9. def tinfoil_init(self, tinfoil):
  10. self.tinfoil = tinfoil
  11. self.bblayers = (self.tinfoil.config_data.getVar('BBLAYERS', True) or "").split()
  12. layerconfs = self.tinfoil.config_data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS', self.tinfoil.config_data)
  13. self.bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.items()}
  14. @staticmethod
  15. def add_command(subparsers, cmdname, function, parserecipes=True, *args, **kwargs):
  16. """Convert docstring for function to help."""
  17. docsplit = function.__doc__.splitlines()
  18. help = docsplit[0]
  19. if len(docsplit) > 1:
  20. desc = '\n'.join(docsplit[1:])
  21. else:
  22. desc = help
  23. subparser = subparsers.add_parser(cmdname, *args, help=help, description=desc, formatter_class=argparse.RawTextHelpFormatter, **kwargs)
  24. subparser.set_defaults(func=function, parserecipes=parserecipes)
  25. return subparser
  26. def get_layer_name(self, layerdir):
  27. return os.path.basename(layerdir.rstrip(os.sep))