Run os.path.expanduser() on all args paths (!1731)
Properly replace ~ with $HOME in all paths. Fix tab completion when passing a path starting with ~ to pmaports: $ pmbootstrap --aports ~/src/pmaports/ build linux-<TAB>
This commit is contained in:
parent
1662fc1961
commit
23df933db4
|
@ -111,9 +111,12 @@ def check_pmaports_path(args):
|
|||
" not exist: " + args.aports)
|
||||
|
||||
|
||||
def replace_variables(args):
|
||||
""" Replace $WORK in variables from any config (user's config file, default
|
||||
config settings or config parameters specified on commandline) """
|
||||
def replace_placeholders(args):
|
||||
""" Replace $WORK and ~ (for path variables) in variables from any config
|
||||
(user's config file, default config settings or config parameters
|
||||
specified on commandline) """
|
||||
|
||||
# Replace $WORK
|
||||
for key, value in pmb.config.defaults.items():
|
||||
if key not in args:
|
||||
continue
|
||||
|
@ -121,6 +124,11 @@ def replace_variables(args):
|
|||
if isinstance(old, str):
|
||||
setattr(args, key, old.replace("$WORK", args.work))
|
||||
|
||||
# Replace ~ (path variables only)
|
||||
for key in ["aports", "config", "log", "work"]:
|
||||
if key in args:
|
||||
setattr(args, key, os.path.expanduser(getattr(args, key)))
|
||||
|
||||
|
||||
def add_shortcuts(args):
|
||||
""" Add convenience shortcuts """
|
||||
|
@ -157,7 +165,7 @@ def init(args):
|
|||
# Basic initialization
|
||||
fix_mirrors_postmarketos(args)
|
||||
pmb.config.merge_with_args(args)
|
||||
replace_variables(args)
|
||||
replace_placeholders(args)
|
||||
add_shortcuts(args)
|
||||
add_cache(args)
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ def arguments_repo_missing(subparser):
|
|||
def packagecompleter(prefix, action, parser, parsed_args):
|
||||
args = parsed_args
|
||||
pmb.config.merge_with_args(args)
|
||||
pmb.helpers.args.replace_variables(args)
|
||||
pmb.helpers.args.replace_placeholders(args)
|
||||
packages = set(pmb.helpers.pmaports.get_list(args))
|
||||
return packages
|
||||
|
||||
|
|
Loading…
Reference in New Issue