예제 #1
0
def main():
    Kernel().get_instance()
    boot()

    parser = argparse.ArgumentParser(
        description='Create and test re-usable tools')
    subparsers = parser.add_subparsers()

    for library_key, library in Kernel.get_instance().get_libraries().items():
        library_group = subparsers.add_parser(
            library_key, description=library.description())
        library_subparsers = library_group.add_subparsers()

        for command, operation in library.operations().items():
            operation_subparser = library_subparsers.add_parser(
                command, description=operation.description())
            operation.parser(operation_subparser)
            operation_subparser.set_defaults(function=operation.execute)

    try:
        results, unknown_args = parser.parse_known_args()
        results.function(results, unknown_args)
    except AttributeError as err:
        print(str(err))
        parser.print_help()
        sys.exit(1)
예제 #2
0
def boot():
    Kernel.get_instance().set_libraries({
        Base.name(): Base()
    })

    Kernel.get_instance().set_observers({
        #operation().__class__ : [
        #   observer().__class__
        # ]
    })
예제 #3
0
 def _run(self):
     operation = Kernel.get_instance().find_operation(
         self.args.library, self.args.operation)
     if operation.is_publishable():
         operation.publish(
             os.path.join('resources', self.args.library,
                          self.args.operation))
         return
     raise Exception("This operation is not publishable")
예제 #4
0
 def _run(self):
     headers = ['Library', 'Command', 'Operation', 'Description']
     data = []
     for library, library_class in Kernel.get_instance().get_libraries(
     ).items():
         for operation, operation_class in library_class.operations().items(
         ):
             data.append([
                 colored(library, 'blue'),
                 colored(operation, 'green'),
                 operation_class.name(),
                 operation_class.description()[:50]
             ])
     print(tabulate.tabulate(data, headers))
     return True
예제 #5
0
 def _run(self):
     create_operation_type(
         Kernel.get_instance().find_library(self.args.library),
         self.args.type)
     return True
예제 #6
0
 def _run(self):
     operation_create(Kernel.get_instance().find_library(self.args.library),
                      self.args.library, self.args.operation)
     return
예제 #7
0
def boot():
    Kernel.get_instance().set_libraries({Base.name(): Base()})

    Kernel.get_instance().set_observers({})