0
@@ -832,6 +832,8 @@ def _disconnect():
0
def _lazy_format(string, env=ENV):
0
"Do recursive string substitution of ENV vars - both lazy and earger."
0
def replacer_fn(match):
0
var = match.group('var')
0
@@ -905,55 +907,41 @@ def _pick_fabfile():
0
- if cmd.find(':') != -1:
0
- cmd_name, cmd_args = cmd.split(':', 1)
0
- if cmd_args is not None:
0
- for cmd_arg_kv in cmd_args.split(','):
0
+ cmd, cmd_str_args = cmd.split(':', 1)
0
+ for cmd_arg_kv in cmd_str_args.split(','):
0
k, _, v = cmd_arg_kv.partition('=')
0
- cmd_arg_kvs[k] = (v % ENV)
0
- cmd_args = cmd_arg_kvs
0
- cmds.append((cmd_name, cmd_args))
0
+ cmd_args[k] = (v % ENV)
0
+ cmds.append((cmd, cmd_args))
0
-def _validate_commands(args):
0
- if cmd.find(':') != -1:
0
- cmd = cmd.split(':', 1)[0]
0
- if not cmd in COMMANDS:
0
- print("No such command: %s" % cmd)
0
+def _validate_commands(cmds):
0
print("No commands given.")
0
+ if not cmd[0] in COMMANDS:
0
+ print("No such command: %s" % cmd[0])
0
-def _execute_commands(args):
0
- if cmd.find(':') != -1:
0
- cmd_name, cmd_args = cmd.split(':', 1)
0
- ENV['fab_cur_command'] = cmd_name
0
- print("Running %s..." % cmd_name)
0
- if cmd_args is not None:
0
- for cmd_arg_kv in cmd_args.split(','):
0
- k, _, v = cmd_arg_kv.partition('=')
0
- cmd_arg_kvs[k] = (v % ENV)
0
- COMMANDS[cmd_name](**cmd_arg_kvs)
0
+def _execute_commands(cmds):
0
+ for cmd, args in cmds:
0
+ ENV['fab_cur_command'] = cmd
0
+ print("Running %s..." % cmd)
0
+ args = dict(zip(args.keys(), map(_lazy_format, args.values())))
0
+ COMMANDS[cmd](**(args and args or {}))
0
print(__greeter__ % ENV)
0
fabfile = _pick_fabfile()
0
- _validate_commands(args)
0
- _execute_commands(args)
0
+ commands = _parse_args(args)
0
+ _validate_commands(commands)
0
+ _execute_commands(commands)
Comments
No one has commented yet.