in modular_cli/service/help_client.py [0:0]
def generate_module_meta(self, modules_meta, requested_command):
prepared_command_path = self.prepare_command_path(
requested_command=requested_command)
subgroups_name = []
commands_names = []
existed_command_paths = []
groups_name = []
pretty_module_name = requested_command[0]
module_commands = modules_meta.get(pretty_module_name)
if not module_commands:
raise ModularCliBadRequestException(
'Can not found requested module')
for commands_meta in module_commands:
for group, command_meta in commands_meta.items():
command_route_path = command_meta['route']['path']
group_name, subgroup_name = \
self.extract_subgroup_from_command_path(
command_path=command_route_path)
if prepared_command_path not in command_meta['route']['path']:
continue
command_name = command_meta['name']
if subgroup_name and subgroup_name not in subgroups_name:
subgroups_name.append(subgroup_name)
if command_name and command_name not in commands_names \
and not subgroup_name:
commands_names.append(command_name)
if group_name and group_name not in groups_name \
and group_name not in subgroups_name:
groups_name.append(group_name)
existed_command_paths.append({
'group': group_name,
'subgroup': subgroup_name,
'command_meta': command_meta
})
if not any([existed_command_paths, subgroups_name, commands_names,
groups_name]):
raise ModularCliBadRequestException('Invalid group or command '
'requested')
return existed_command_paths, subgroups_name, commands_names, groups_name