Пример #1
0
    def start(self):
        access_levels = {}

        # process decorators
        for _, inst in Registry.get_all_instances().items():
            for name, method in get_attrs(inst).items():
                if hasattr(method, "command"):
                    cmd_name, params, access_level, description, help_file, sub_command, extended_description = getattr(
                        method, "command")
                    handler = getattr(inst, name)
                    help_text = self.get_help_file(inst.module_name, help_file)

                    command_key = self.get_command_key(
                        cmd_name.lower(),
                        sub_command.lower() if sub_command else "")
                    al = access_levels.get(command_key, None)
                    if al is not None and al != access_level.lower():
                        raise Exception(
                            "Different access levels specified for forms of command '%s'"
                            % command_key)
                    access_levels[command_key] = access_level

                    self.register(handler, cmd_name, params, access_level,
                                  description, inst.module_name, help_text,
                                  sub_command, extended_description)
Пример #2
0
 def start(self):
     # process decorators
     for _, inst in Registry.get_all_instances().items():
         for name, method in get_attrs(inst).items():
             if hasattr(method, "setting"):
                 setting_name, value, description, extended_description, obj = getattr(method, "setting")
                 self.register(inst.module_name, setting_name, value, obj, description, extended_description)
Пример #3
0
 def start(self):
     # process decorators
     for _, inst in Registry.get_all_instances().items():
         for name, method in get_attrs(inst).items():
             if hasattr(method, "event"):
                 attrs = getattr(method, "event")
                 handler = getattr(inst, name)
                 self.register(handler, attrs.event_type, attrs.description, inst.module_name, attrs.is_hidden, attrs.is_enabled)