[options] Fix aliases to --config-location
This commit is contained in:
parent
44f14eb43e
commit
284a60c516
2 changed files with 14 additions and 6 deletions
|
@ -114,6 +114,11 @@ def parseOpts(overrideArguments=None, ignore_config_files='if_override'):
|
||||||
if user_conf is not None:
|
if user_conf is not None:
|
||||||
root.configs.pop(user_conf)
|
root.configs.pop(user_conf)
|
||||||
|
|
||||||
|
try:
|
||||||
|
root.configs[0].load_configs() # Resolve any aliases using --config-location
|
||||||
|
except ValueError as err:
|
||||||
|
raise root.parser.error(err)
|
||||||
|
|
||||||
opts, args = root.parse_args()
|
opts, args = root.parse_args()
|
||||||
except optparse.OptParseError:
|
except optparse.OptParseError:
|
||||||
with contextlib.suppress(optparse.OptParseError):
|
with contextlib.suppress(optparse.OptParseError):
|
||||||
|
|
|
@ -5393,18 +5393,21 @@ class Config:
|
||||||
|
|
||||||
def init(self, args=None, filename=None):
|
def init(self, args=None, filename=None):
|
||||||
assert not self.__initialized
|
assert not self.__initialized
|
||||||
|
self.own_args, self.filename = args, filename
|
||||||
|
return self.load_configs()
|
||||||
|
|
||||||
|
def load_configs(self):
|
||||||
directory = ''
|
directory = ''
|
||||||
if filename:
|
if self.filename:
|
||||||
location = os.path.realpath(filename)
|
location = os.path.realpath(self.filename)
|
||||||
directory = os.path.dirname(location)
|
directory = os.path.dirname(location)
|
||||||
if location in self._loaded_paths:
|
if location in self._loaded_paths:
|
||||||
return False
|
return False
|
||||||
self._loaded_paths.add(location)
|
self._loaded_paths.add(location)
|
||||||
|
|
||||||
self.own_args, self.__initialized = args, True
|
self.__initialized = True
|
||||||
opts, _ = self.parser.parse_known_args(args)
|
opts, _ = self.parser.parse_known_args(self.own_args)
|
||||||
self.parsed_args, self.filename = args, filename
|
self.parsed_args = self.own_args
|
||||||
|
|
||||||
for location in opts.config_locations or []:
|
for location in opts.config_locations or []:
|
||||||
if location == '-':
|
if location == '-':
|
||||||
self.append_config(shlex.split(read_stdin('options'), comments=True), label='stdin')
|
self.append_config(shlex.split(read_stdin('options'), comments=True), label='stdin')
|
||||||
|
|
Loading…
Reference in a new issue