fixed issue with paths separator and others

finished  normalizing of path handling
removed overloaded '-p' from init_paths option, it is for role_paths
removed expand_tilde and get_opt methods as both were redundant, adjusted rest of code
updated tests to match
This commit is contained in:
Brian Coca 2017-06-15 14:32:37 -04:00
commit fedbf3666b
3 changed files with 21 additions and 36 deletions

View file

@ -276,14 +276,14 @@ class CLI(with_metaclass(ABCMeta, object)):
if op.forks < 1:
self.parser.error("The number of processes (--forks) must be >= 1")
@staticmethod
def expand_tilde(option, opt, value, parser):
setattr(parser.values, option.dest, os.path.expanduser(value))
@staticmethod
def unfrack_paths(option, opt, value, parser):
if isinstance(value, string_types):
setattr(parser.values, option.dest, [unfrackpath(x) for x in value.split(os.sep)])
setattr(parser.values, option.dest, [unfrackpath(x) for x in value.split(os.pathsep)])
elif isinstance(value, list):
setattr(parser.values, option.dest, [unfrackpath(x) for x in value])
else:
pass #FIXME: should we raise options error?
@staticmethod
def unfrack_path(option, opt, value, parser):
@ -312,7 +312,7 @@ class CLI(with_metaclass(ABCMeta, object)):
if module_opts:
parser.add_option('-M', '--module-path', dest='module_path', default=None,
help="prepend path(s) to module library (default=%s)" % C.DEFAULT_MODULE_PATH,
action="callback", callback=CLI.expand_tilde, type=str)
action="callback", callback=CLI.unfrack_path, type='str')
if runtask_opts:
parser.add_option('-e', '--extra-vars', dest="extra_vars", action="append",
help="set additional variables as key=value or YAML/JSON", default=[])