string.format with numeric parameters

This commit is contained in:
gwen 2013-07-02 15:05:50 +02:00
parent 4b5d9b4229
commit b80bef0f7e

View file

@ -346,7 +346,7 @@ class Option(BaseInformation):
raise ValueError('cannot add consistency with itself')
if self.impl_is_multi() != opt.impl_is_multi():
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._consistencies.append((func, opt))
self.impl_validate(self.impl_getdefault())
@ -519,7 +519,7 @@ class NetmaskOption(Option):
def _validate(self, value):
try:
IP('0.0.0.0/{}'.format(value))
IP('0.0.0.0/{0}'.format(value))
return True
except ValueError:
return False
@ -665,7 +665,7 @@ class OptionDescription(BaseInformation):
try:
return self._children[1][self._children[0].index(name)]
except ValueError:
raise AttributeError(_('unknown Option {} in OptionDescription {}'
raise AttributeError(_('unknown Option {0} in OptionDescription {1}'
'').format(name, self._name))
def impl_getkey(self, config):
@ -739,13 +739,13 @@ class OptionDescription(BaseInformation):
try:
return self._cache_paths[0][self._cache_paths[1].index(path)]
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):
try:
return self._cache_paths[1][self._cache_paths[0].index(opt)]
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):
@ -756,7 +756,7 @@ class OptionDescription(BaseInformation):
"""
if self._group_type != groups.default:
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):
self._group_type = group_type
if isinstance(group_type, groups.MasterGroupType):
@ -767,10 +767,10 @@ class OptionDescription(BaseInformation):
master = None
for child in self.impl_getchildren():
if isinstance(child, OptionDescription):
raise ValueError(_("master group {} shall not have "
raise ValueError(_("master group {0} shall not have "
"a subgroup").format(self._name))
if isinstance(child, SymLinkOption):
raise ValueError(_("master group {} shall not have "
raise ValueError(_("master group {0} shall not have "
"a symlinkoption").format(self._name))
if not child.impl_is_multi():
raise ValueError(_("not allowed option {0} in group {1}"
@ -783,7 +783,7 @@ class OptionDescription(BaseInformation):
else:
slaves.append(child)
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))
master._master_slaves = tuple(slaves)
for child in self.impl_getchildren():
@ -791,7 +791,7 @@ class OptionDescription(BaseInformation):
child._master_slaves = master
child._multitype = multitypes.slave
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))
else:
raise ValueError(_('not allowed group_type : {0}').format(group_type))