def _validate_args(parser, namespace): path = namespace.profile if namespace.repo is not None and getattr(namespace.repo, 'location', False): if not path.startswith('/'): path = pjoin(namespace.repo.location, 'profiles', path) try: stack = profiles.ProfileStack(arghparse.existent_path(path)) except ValueError as e: parser.error(e) if stack.node.repoconfig is None: parser.error("invalid profile path: '%s'" % path) namespace.profile = stack
def _validate_args(parser, namespace): path = namespace.profile if path is None: if namespace.repo is not None: # default to the repo's main profiles dir path = pjoin(namespace.repo.location, 'profiles') else: # default to the configured system profile if none is selected path = namespace.config.get_default("domain").profile.profile else: if namespace.repo is not None and getattr(namespace.repo, 'location', False): if not path.startswith('/'): path = pjoin(namespace.repo.location, 'profiles', path) try: stack = profiles.ProfileStack(arghparse.existent_path(path)) except argparse.ArgumentTypeError as e: parser.error(e) if stack.node.repoconfig is None: parser.error(f"invalid profile path: {path!r}") namespace.profile = stack
def __call__(self, parser, namespace, value, option_string=None): if value.lower() in {'false', 'no', 'n'}: path = pjoin(const.DATA_PATH, 'stubconfig') else: path = arghparse.existent_path(value) setattr(namespace, self.dest, path)