summaryrefslogtreecommitdiffstats
path: root/lib/bbsetup/common.py
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2017-07-17 22:37:17 -0500
committerMark Hatle <mark.hatle@windriver.com>2017-09-06 11:53:57 -0500
commit221efcbcc8c2e01a25ed3fb25fb8740f0f497938 (patch)
treec235c8784987fc4a73e5266d944fdcf3634d6ab5 /lib/bbsetup/common.py
parent102430f42561327546964fd9caef72c8a56fbe64 (diff)
downloadbitbake-contrib-mgh/bitbake-setup.tar.gz
bitbake-contrib-mgh/bitbake-setup.tar.bz2
bitbake-contrib-mgh/bitbake-setup.zip
bitbake-setup: Add WIP implementation of bitbake-setup [DO NOT MERGE]mgh/bitbake-setup
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'lib/bbsetup/common.py')
-rw-r--r--lib/bbsetup/common.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/bbsetup/common.py b/lib/bbsetup/common.py
new file mode 100644
index 0000000000..eff7624af6
--- /dev/null
+++ b/lib/bbsetup/common.py
@@ -0,0 +1,31 @@
+import argparse
+import logging
+import os
+import bb.msg
+
+logger = logging.getLogger('BitBake.BBSetup.common')
+
+
+class SetupPlugin():
+ def __init__(self):
+ data = None
+
+ def init(self, d):
+ self.data = d
+
+ @staticmethod
+ def add_command(subparsers, cmdname, function, *args, **kwargs):
+ """Convert docstring for function to help."""
+ logger.debug(1, 'Adding command: %s' % cmdname)
+ docsplit = function.__doc__.splitlines()
+ help = docsplit[0]
+ if len(docsplit) > 1:
+ desc = '\n'.join(docsplit[1:])
+ else:
+ desc = help
+ subparser = subparsers.add_parser(cmdname, *args, help=help, description=desc, formatter_class=argparse.RawTextHelpFormatter, **kwargs)
+ subparser.set_defaults(func=function)
+ return subparser
+
+ def get_layer_name(self, layerdir):
+ return os.path.basename(layerdir.rstrip(os.sep))