string.format with numeric parameters
This commit is contained in:
parent
4b5d9b4229
commit
b80bef0f7e
|
@ -346,7 +346,7 @@ class Option(BaseInformation):
|
||||||
raise ValueError('cannot add consistency with itself')
|
raise ValueError('cannot add consistency with itself')
|
||||||
if self.impl_is_multi() != opt.impl_is_multi():
|
if self.impl_is_multi() != opt.impl_is_multi():
|
||||||
raise ValueError('options in consistency should be multi in two sides')
|
raise ValueError('options in consistency should be multi in two sides')
|
||||||
func = '_cons_{}'.format(func)
|
func = '_cons_{0}'.format(func)
|
||||||
self._launch_consistency(func, self, self.impl_getdefault(), None, None, opt)
|
self._launch_consistency(func, self, self.impl_getdefault(), None, None, opt)
|
||||||
self._consistencies.append((func, opt))
|
self._consistencies.append((func, opt))
|
||||||
self.impl_validate(self.impl_getdefault())
|
self.impl_validate(self.impl_getdefault())
|
||||||
|
@ -519,7 +519,7 @@ class NetmaskOption(Option):
|
||||||
|
|
||||||
def _validate(self, value):
|
def _validate(self, value):
|
||||||
try:
|
try:
|
||||||
IP('0.0.0.0/{}'.format(value))
|
IP('0.0.0.0/{0}'.format(value))
|
||||||
return True
|
return True
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
@ -665,7 +665,7 @@ class OptionDescription(BaseInformation):
|
||||||
try:
|
try:
|
||||||
return self._children[1][self._children[0].index(name)]
|
return self._children[1][self._children[0].index(name)]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise AttributeError(_('unknown Option {} in OptionDescription {}'
|
raise AttributeError(_('unknown Option {0} in OptionDescription {1}'
|
||||||
'').format(name, self._name))
|
'').format(name, self._name))
|
||||||
|
|
||||||
def impl_getkey(self, config):
|
def impl_getkey(self, config):
|
||||||
|
@ -739,13 +739,13 @@ class OptionDescription(BaseInformation):
|
||||||
try:
|
try:
|
||||||
return self._cache_paths[0][self._cache_paths[1].index(path)]
|
return self._cache_paths[0][self._cache_paths[1].index(path)]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise AttributeError(_('no option for path {}').format(path))
|
raise AttributeError(_('no option for path {0}').format(path))
|
||||||
|
|
||||||
def impl_get_path_by_opt(self, opt):
|
def impl_get_path_by_opt(self, opt):
|
||||||
try:
|
try:
|
||||||
return self._cache_paths[1][self._cache_paths[0].index(opt)]
|
return self._cache_paths[1][self._cache_paths[0].index(opt)]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise AttributeError(_('no option {} found').format(opt))
|
raise AttributeError(_('no option {0} found').format(opt))
|
||||||
|
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
def impl_set_group_type(self, group_type):
|
def impl_set_group_type(self, group_type):
|
||||||
|
@ -756,7 +756,7 @@ class OptionDescription(BaseInformation):
|
||||||
"""
|
"""
|
||||||
if self._group_type != groups.default:
|
if self._group_type != groups.default:
|
||||||
raise TypeError(_('cannot change group_type if already set '
|
raise TypeError(_('cannot change group_type if already set '
|
||||||
'(old {}, new {})').format(self._group_type, group_type))
|
'(old {0}, new {1})').format(self._group_type, group_type))
|
||||||
if isinstance(group_type, groups.GroupType):
|
if isinstance(group_type, groups.GroupType):
|
||||||
self._group_type = group_type
|
self._group_type = group_type
|
||||||
if isinstance(group_type, groups.MasterGroupType):
|
if isinstance(group_type, groups.MasterGroupType):
|
||||||
|
@ -767,10 +767,10 @@ class OptionDescription(BaseInformation):
|
||||||
master = None
|
master = None
|
||||||
for child in self.impl_getchildren():
|
for child in self.impl_getchildren():
|
||||||
if isinstance(child, OptionDescription):
|
if isinstance(child, OptionDescription):
|
||||||
raise ValueError(_("master group {} shall not have "
|
raise ValueError(_("master group {0} shall not have "
|
||||||
"a subgroup").format(self._name))
|
"a subgroup").format(self._name))
|
||||||
if isinstance(child, SymLinkOption):
|
if isinstance(child, SymLinkOption):
|
||||||
raise ValueError(_("master group {} shall not have "
|
raise ValueError(_("master group {0} shall not have "
|
||||||
"a symlinkoption").format(self._name))
|
"a symlinkoption").format(self._name))
|
||||||
if not child.impl_is_multi():
|
if not child.impl_is_multi():
|
||||||
raise ValueError(_("not allowed option {0} in group {1}"
|
raise ValueError(_("not allowed option {0} in group {1}"
|
||||||
|
@ -783,7 +783,7 @@ class OptionDescription(BaseInformation):
|
||||||
else:
|
else:
|
||||||
slaves.append(child)
|
slaves.append(child)
|
||||||
if master is None:
|
if master is None:
|
||||||
raise ValueError(_('master group with wrong master name for {}'
|
raise ValueError(_('master group with wrong master name for {0}'
|
||||||
'').format(self._name))
|
'').format(self._name))
|
||||||
master._master_slaves = tuple(slaves)
|
master._master_slaves = tuple(slaves)
|
||||||
for child in self.impl_getchildren():
|
for child in self.impl_getchildren():
|
||||||
|
@ -791,7 +791,7 @@ class OptionDescription(BaseInformation):
|
||||||
child._master_slaves = master
|
child._master_slaves = master
|
||||||
child._multitype = multitypes.slave
|
child._multitype = multitypes.slave
|
||||||
if not identical_master_child_name:
|
if not identical_master_child_name:
|
||||||
raise ValueError(_("the master group: {} has not any "
|
raise ValueError(_("the master group: {0} has not any "
|
||||||
"master child").format(self._name))
|
"master child").format(self._name))
|
||||||
else:
|
else:
|
||||||
raise ValueError(_('not allowed group_type : {0}').format(group_type))
|
raise ValueError(_('not allowed group_type : {0}').format(group_type))
|
||||||
|
|
Loading…
Reference in New Issue