Fixed i18n formatting
This commit is contained in:
committed by
Rajaram Mallya
parent
dc8f68e24d
commit
2cf5db5a61
@@ -56,7 +56,7 @@ class TenantBasedAuth(object):
|
||||
match = self.tenant_scoped_url.match(request.path_info)
|
||||
if match and tenant_id != match.group('tenant_id'):
|
||||
raise HTTPForbidden(_("User with tenant id %s cannot access "
|
||||
"this resource" % tenant_id))
|
||||
"this resource") % tenant_id)
|
||||
return True
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class RoleBasedAuth(object):
|
||||
match = self.mapper.match(request.path_info, request.environ)
|
||||
if match and match['action'] in match['controller'].admin_actions:
|
||||
raise HTTPForbidden(_("User with roles %s cannot access "
|
||||
"admin actions" % ', '.join(roles)))
|
||||
"admin actions") % ', '.join(roles))
|
||||
return True
|
||||
|
||||
|
||||
@@ -94,6 +94,6 @@ class KeystoneClient(httplib2.Http):
|
||||
res, body = self.request(self.url, "POST", headers=headers,
|
||||
body=request_body)
|
||||
if int(res.status) >= 400:
|
||||
raise Exception(_("Error occured while retrieving token : %s"
|
||||
% body))
|
||||
raise Exception(_("Error occured while retrieving token : %s")
|
||||
% body)
|
||||
return json.loads(body)['auth']['token']['id']
|
||||
|
||||
@@ -55,4 +55,4 @@ class Client(object):
|
||||
return response
|
||||
except (socket.error, IOError), e:
|
||||
raise Exception(_("Unable to connect to "
|
||||
"server. Got error: %s" % e))
|
||||
"server. Got error: %s") % e)
|
||||
|
||||
@@ -129,7 +129,7 @@ def setup_logging(options, conf):
|
||||
return
|
||||
else:
|
||||
raise RuntimeError(_("Unable to locate specified logging "
|
||||
"config file: %s" % options['log_config']))
|
||||
"config file: %s") % options['log_config'])
|
||||
|
||||
# If either the CLI option or the conf value
|
||||
# is True, we set to True
|
||||
@@ -240,13 +240,13 @@ def load_paste_config(app_name, options, args):
|
||||
conf_file = find_config_file(options, args)
|
||||
if not conf_file:
|
||||
raise RuntimeError(_("Unable to locate any configuration file. "
|
||||
"Cannot load application %s" % app_name))
|
||||
"Cannot load application %s") % app_name)
|
||||
try:
|
||||
conf = deploy.appconfig("config:%s" % conf_file, name=app_name)
|
||||
return conf_file, conf
|
||||
except Exception, error:
|
||||
raise RuntimeError(_("Error trying to load config %(conf_file)s:"
|
||||
" %(error)s" % locals()))
|
||||
" %(error)s") % locals())
|
||||
|
||||
|
||||
def load_paste_app(app_name, options, args):
|
||||
@@ -301,8 +301,8 @@ def load_paste_app(app_name, options, args):
|
||||
app = deploy.loadapp("config:%s" % conf_file, name=app_name)
|
||||
except (LookupError, ImportError), e:
|
||||
raise RuntimeError(_("Unable to load %(app_name)s from "
|
||||
"configuration file %(conf_file)s."
|
||||
"\nGot: %(e)r" % locals()))
|
||||
"configuration file %(conf_file)s."
|
||||
"\nGot: %(e)r") % locals())
|
||||
return conf, app
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ def get_option(options, option, **kwargs):
|
||||
elif 'default' in kwargs:
|
||||
return kwargs['default']
|
||||
else:
|
||||
raise KeyError(_("option '%s' not found" % option))
|
||||
raise KeyError(_("option '%s' not found") % option)
|
||||
|
||||
|
||||
class Config(object):
|
||||
|
||||
@@ -398,8 +398,8 @@ class ExtensionManager(object):
|
||||
self._check_extension(ext)
|
||||
|
||||
if alias in self.extensions:
|
||||
raise exception.MelangeError(_("Found duplicate extension: %s"
|
||||
% alias))
|
||||
raise exception.MelangeError(_("Found duplicate extension: %s")
|
||||
% alias)
|
||||
self.extensions[alias] = ext
|
||||
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ class Request(webob.Request):
|
||||
return type
|
||||
LOG.debug("Wrong Content-Type: %s" % type)
|
||||
raise webob.exc.HTTPUnsupportedMediaType(
|
||||
_("Content type %s not supported" % type))
|
||||
_("Content type %s not supported") % type)
|
||||
|
||||
@cached_property
|
||||
def accept_version(self):
|
||||
|
||||
@@ -95,8 +95,8 @@ class ModelBase(object):
|
||||
except (TypeError, ValueError):
|
||||
type_name = column_type.__name__
|
||||
self._add_error(column_name,
|
||||
_("%(column_name)s should be of type %(type_name)s"
|
||||
% locals()))
|
||||
_("%(column_name)s should be of type %(type_name)s")
|
||||
% locals())
|
||||
|
||||
def _validate(self):
|
||||
pass
|
||||
@@ -121,8 +121,8 @@ class ModelBase(object):
|
||||
def _validate_presence_of(self, attribute_name):
|
||||
if (self[attribute_name] in [None, ""]):
|
||||
self._add_error(attribute_name,
|
||||
_("%(attribute_name)s should be present"
|
||||
% locals()))
|
||||
_("%(attribute_name)s should be present")
|
||||
% locals())
|
||||
|
||||
def _validate_existence_of(self, attribute, model_class, **conditions):
|
||||
model_id = self[attribute]
|
||||
@@ -133,7 +133,7 @@ class ModelBase(object):
|
||||
model_class_name = model_class.__name__
|
||||
self._add_error(attribute,
|
||||
_("%(model_class_name)s with %(conditions_str)s"
|
||||
" doesn't exist" % locals()))
|
||||
" doesn't exist") % locals())
|
||||
|
||||
@classmethod
|
||||
def find(cls, id):
|
||||
@@ -147,7 +147,7 @@ class ModelBase(object):
|
||||
def find_by(cls, **conditions):
|
||||
model = cls.get_by(**conditions)
|
||||
if model == None:
|
||||
raise ModelNotFoundError(_("%s Not Found" % cls.__name__))
|
||||
raise ModelNotFoundError(_("%s Not Found") % cls.__name__)
|
||||
return model
|
||||
|
||||
@classmethod
|
||||
@@ -217,8 +217,8 @@ class ModelBase(object):
|
||||
def _validate_positive_integer(self, attribute_name):
|
||||
if(utils.parse_int(self[attribute_name]) < 0):
|
||||
self._add_error(attribute_name,
|
||||
_("%s should be a positive integer"
|
||||
% attribute_name))
|
||||
_("%s should be a positive integer")
|
||||
% attribute_name)
|
||||
|
||||
def _add_error(self, attribute_name, error_message):
|
||||
self.errors[attribute_name] = self.errors.get(attribute_name, [])
|
||||
@@ -237,8 +237,8 @@ def ipv6_address_generator_factory(cidr, **kwargs):
|
||||
if hasattr(ip_generator, "required_params") else []
|
||||
missing_params = set(required_params) - set(kwargs.keys())
|
||||
if missing_params:
|
||||
raise DataMissingError(_("Required params are missing: %s"
|
||||
% (', '.join(missing_params))))
|
||||
raise DataMissingError(_("Required params are missing: %s")
|
||||
% (', '.join(missing_params)))
|
||||
return ip_generator(cidr, **kwargs)
|
||||
|
||||
|
||||
@@ -426,8 +426,8 @@ class IpBlock(ModelBase):
|
||||
|
||||
def _validate_type(self):
|
||||
if not (self.type in self._allowed_types):
|
||||
self._add_error('type', _("type should be one among %s" %
|
||||
(", ".join(self._allowed_types))))
|
||||
self._add_error('type', _("type should be one among %s") %
|
||||
", ".join(self._allowed_types))
|
||||
|
||||
def _validate_cidr(self):
|
||||
self._validate_cidr_format()
|
||||
@@ -444,14 +444,14 @@ class IpBlock(ModelBase):
|
||||
return
|
||||
for block in IpBlock.find_all(type='public', parent_id=None):
|
||||
if self != block and self._overlaps(block):
|
||||
msg = _("cidr overlaps with public block %s" % block.cidr)
|
||||
msg = _("cidr overlaps with public block %s") % block.cidr
|
||||
self._add_error('cidr', msg)
|
||||
break
|
||||
|
||||
def _validate_cidr_does_not_overlap_with_siblings(self):
|
||||
for sibling in self.siblings():
|
||||
if self._overlaps(sibling):
|
||||
msg = _("cidr overlaps with sibling %s" % sibling.cidr)
|
||||
msg = _("cidr overlaps with sibling %s") % sibling.cidr
|
||||
self._add_error('cidr', msg)
|
||||
break
|
||||
|
||||
@@ -469,7 +469,7 @@ class IpBlock(ModelBase):
|
||||
for block in self.networked_top_level_blocks():
|
||||
if self._overlaps(block):
|
||||
self._add_error('cidr', _("cidr overlaps with block %s"
|
||||
" in same network" % block.cidr))
|
||||
" in same network") % block.cidr)
|
||||
break
|
||||
|
||||
def _validate_belongs_to_supernet_network(self):
|
||||
@@ -658,7 +658,7 @@ class Network(ModelBase):
|
||||
def find_by(cls, id, tenant_id=None):
|
||||
ip_blocks = IpBlock.find_all(network_id=id, tenant_id=tenant_id).all()
|
||||
if(len(ip_blocks) == 0):
|
||||
raise ModelNotFoundError(_("Network %s not found" % id))
|
||||
raise ModelNotFoundError(_("Network %s not found") % id)
|
||||
return cls(id=id, ip_blocks=ip_blocks)
|
||||
|
||||
@classmethod
|
||||
@@ -767,7 +767,7 @@ class InvalidModelError(MelangeError):
|
||||
super(InvalidModelError, self).__init__(message)
|
||||
|
||||
def __str__(self):
|
||||
return _("The following values are invalid: %s" % str(self.errors))
|
||||
return _("The following values are invalid: %s") % str(self.errors)
|
||||
|
||||
def _error_message(self):
|
||||
return str(self)
|
||||
|
||||
Reference in New Issue
Block a user