Fix attribute heritance for long commands.
This is needed for inheritance to work with commands that have dashes in their names.
This commit is contained in:
parent
e7f6e90a22
commit
1f86e8ae9a
1 changed files with 7 additions and 4 deletions
|
@ -511,7 +511,10 @@ class MILC(object):
|
||||||
|
|
||||||
if argument not in self.arg_only:
|
if argument not in self.arg_only:
|
||||||
# Find the argument's section
|
# Find the argument's section
|
||||||
if self._entrypoint.__name__ in self.default_arguments and argument in self.default_arguments[self._entrypoint.__name__]:
|
# Underscores in command's names are converted to dashes during initialization.
|
||||||
|
# TODO(Erovia) Find a better solution
|
||||||
|
entrypoint_name = self._entrypoint.__name__.replace("_", "-")
|
||||||
|
if entrypoint_name in self.default_arguments and argument in self.default_arguments[entrypoint_name]:
|
||||||
argument_found = True
|
argument_found = True
|
||||||
section = self._entrypoint.__name__
|
section = self._entrypoint.__name__
|
||||||
if argument in self.default_arguments['general']:
|
if argument in self.default_arguments['general']:
|
||||||
|
@ -523,12 +526,12 @@ class MILC(object):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Merge this argument into self.config
|
# Merge this argument into self.config
|
||||||
if argument in self.default_arguments[section]:
|
if argument in self.default_arguments['general'] or argument in self.default_arguments[entrypoint_name]:
|
||||||
arg_value = getattr(self.args, argument)
|
arg_value = getattr(self.args, argument)
|
||||||
if arg_value:
|
if arg_value is not None:
|
||||||
self.config[section][argument] = arg_value
|
self.config[section][argument] = arg_value
|
||||||
else:
|
else:
|
||||||
if argument not in self.config[section]:
|
if argument not in self.config[entrypoint_name]:
|
||||||
# Check if the argument exist for this section
|
# Check if the argument exist for this section
|
||||||
arg = getattr(self.args, argument)
|
arg = getattr(self.args, argument)
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
|
|
Loading…
Reference in a new issue