Commit 794b743e authored by Stavros Sachtouris's avatar Stavros Sachtouris

Rename _commands to namespaces in kamaki.cli.cmds

The underscore is removed because it is a global variable used
outside of the modules it is declared.
The new name is a precise description of what this variable is
used for.
parent 596997be
......@@ -115,7 +115,7 @@ def command(cmd_tree, prefix='', descedants_depth=1):
e.g., spec_cmd0_cmd1 will be command spec cmd0
:param cmd_tree: is initialized in cmd_spec file and is the structure
where commands are loaded. Var name should be _commands
where commands are loaded. Var name should be "namespaces"
:param prefix: if given, load only commands prefixed with prefix,
:param descedants_depth: is the depth of the tree descedants of the
prefix command. It is used ONLY if prefix and if prefix is not
......@@ -366,11 +366,11 @@ def _groups_help(arguments):
descriptions = {}
acceptable_groups = arguments['config'].groups
for cmd_group, spec in arguments['config'].cli_specs:
pkg = _load_spec_module(spec, arguments, '_commands')
pkg = _load_spec_module(spec, arguments, 'namespaces')
if pkg:
cmds = getattr(pkg, '_commands')
namespaces = getattr(pkg, 'namespaces')
try:
for cmd_tree in cmds:
for cmd_tree in namespaces:
if cmd_tree.name in acceptable_groups:
descriptions[cmd_tree.name] = cmd_tree.description
except TypeError:
......@@ -387,14 +387,14 @@ def _load_all_commands(cmd_tree, arguments):
_cnf = arguments['config']
for cmd_group, spec in _cnf.cli_specs:
try:
spec_module = _load_spec_module(spec, arguments, '_commands')
spec_commands = getattr(spec_module, '_commands')
spec_module = _load_spec_module(spec, arguments, 'namespaces')
namespaces = getattr(spec_module, 'namespaces')
except AttributeError:
if _debug:
global kloger
kloger.warning('No valid description for %s' % cmd_group)
continue
for spec_tree in spec_commands:
for spec_tree in namespaces:
if spec_tree.name == cmd_group:
cmd_tree.add_tree(spec_tree)
break
......
This diff is collapsed.
......@@ -38,7 +38,7 @@ from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.errors import CLIError, CLISyntaxError
config_cmds = CommandTree('config', 'Kamaki configurations')
_commands = [config_cmds]
namespaces = [config_cmds, ]
about_options = '\nAbout options:\
\n. syntax: [group.]option\
......
......@@ -52,7 +52,7 @@ from kamaki.cli.cmds import (
server_cmds = CommandTree('server', 'Cyclades/Compute API server commands')
flavor_cmds = CommandTree('flavor', 'Cyclades/Compute API flavor commands')
_commands = [server_cmds, flavor_cmds]
namespaces = [server_cmds, flavor_cmds]
about_authentication = '\nUser Authentication:\
......
......@@ -39,7 +39,7 @@ from kamaki.cli.cmds import CommandInit, errors
history_cmds = CommandTree('history', 'Kamaki command history')
_commands = [history_cmds]
namespaces = [history_cmds]
class _HistoryInit(CommandInit):
......
......@@ -55,7 +55,7 @@ from kamaki.cli.cmds import (
image_cmds = CommandTree('image', 'Cyclades/Plankton API image commands')
imagecompute_cmds = CommandTree(
'imagecompute', 'Cyclades/Compute API image commands')
_commands = [image_cmds, imagecompute_cmds]
namespaces = [image_cmds, imagecompute_cmds]
howto_image_file = [
......
......@@ -51,7 +51,7 @@ network_cmds = CommandTree('network', 'Network API network commands')
port_cmds = CommandTree('port', 'Network API port commands')
subnet_cmds = CommandTree('subnet', 'Network API subnet commands')
ip_cmds = CommandTree('ip', 'Network API floatingip commands')
_commands = [network_cmds, port_cmds, subnet_cmds, ip_cmds]
namespaces = [network_cmds, port_cmds, subnet_cmds, ip_cmds]
about_authentication = '\nUser Authentication:\
......
......@@ -58,7 +58,7 @@ container_cmds = CommandTree(
'container', 'Pithos+/Storage container level API commands')
sharer_cmds = CommandTree('sharer', 'Pithos+/Storage sharers')
group_cmds = CommandTree('group', 'Pithos+/Storage user groups')
_commands = [file_cmds, container_cmds, sharer_cmds, group_cmds]
namespaces = [file_cmds, container_cmds, sharer_cmds, group_cmds]
class _PithosInit(CommandInit):
......
......@@ -71,7 +71,7 @@ def run(cloud, parser, _help):
_cnf = parser.arguments['config']
group_spec = _cnf.get('global', '%s_cli' % group)
spec_module = _load_spec_module(group_spec, parser.arguments, '_commands')
spec_module = _load_spec_module(group_spec, parser.arguments, 'namespaces')
if spec_module is None:
raise CLIUnknownCommand(
'Could not find specs for %s commands' % group,
......@@ -79,7 +79,7 @@ def run(cloud, parser, _help):
'Make sure %s is a valid command group' % group,
'Refer to kamaki documentation for setting custom command',
'groups or overide existing ones'])
cmd_tree = _get_cmd_tree_from_spec(group, spec_module._commands)
cmd_tree = _get_cmd_tree_from_spec(group, spec_module.namespaces)
if _best_match:
cmd = cmd_tree.get_command('_'.join(_best_match))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment