sdbus++: move main to module
The python bytecode cache only caches modules and not scripts.
Move the 'main' function of sdbus++ into the submodule so we get
more code hitting in the bytecode cache, which has a minor speed-up.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I5f20ec14c899a111e1abb073e26229d41e19822c
diff --git a/tools/sdbus++ b/tools/sdbus++
index fa12677..fbbc3cd 100755
--- a/tools/sdbus++
+++ b/tools/sdbus++
@@ -1,45 +1,5 @@
#!/usr/bin/env python3
-import sdbusplus
-import mako.lookup
-import argparse
-import sys
-import os
-
-
-def main():
- module_path = os.path.dirname(sdbusplus.__file__)
-
- valid_types = {'interface': sdbusplus.Interface,
- 'error': sdbusplus.Error}
- valid_processes = {'markdown': "markdown",
- 'server-header': "server_header",
- 'server-cpp': "server_cpp",
- 'exception-header': "exception_header",
- 'exception-cpp': "exception_cpp",
- 'client-header': "client_header"}
-
- parser = argparse.ArgumentParser(description='Process sdbus++ YAML files.')
-
- parser.add_argument('-r', '--rootdir', dest='rootdir', default='.',
- type=str, help='Location of files to process.')
- parser.add_argument('-t', '--templatedir', dest='templatedir',
- default=os.path.join(module_path, 'templates'),
- type=str, help='Location of templates files.')
- parser.add_argument('typeName', metavar='TYPE', type=str,
- choices=valid_types.keys(), help='Type to operate on.')
- parser.add_argument('process', metavar='PROCESS', type=str,
- choices=valid_processes.keys(),
- help='Process to apply.')
- parser.add_argument('item', metavar='ITEM', type=str,
- help='Item to process.')
-
- args = parser.parse_args()
-
- lookup = mako.lookup.TemplateLookup(directories=[args.templatedir])
-
- instance = valid_types[args.typeName].load(args.item, args.rootdir)
- function = getattr(instance, valid_processes[args.process])
- print(function(lookup))
+from sdbusplus.main import main
if __name__ == '__main__':
main()