diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-03-04 19:06:31 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-03-04 22:10:59 +0000 |
| commit | 534a894ad18c180791aaa685e97cc5264acce922 (patch) | |
| tree | 8cd858c0c3d0dc4ebac4871e3024db40d3ab418f /nova/api | |
| parent | 8813ab185d0b6ad1c111e7f9e346e2ce91c8113b (diff) | |
Only raw string literals should be used with _()
Fix a number of places where formatted strings were used with _() (causing
gettext to not match the string) or variables with _() (causing xgettext
to not extract a string)
Also, there's no value in internationalizing an empty string
Change-Id: Iac7dbe46eeaa8ddf03c2a357ecd52f69aa8678aa
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 32 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/disk_config.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/networks.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/compute/limits.py | 6 | ||||
| -rw-r--r-- | nova/api/openstack/wsgi.py | 2 | ||||
| -rw-r--r-- | nova/api/validator.py | 8 |
6 files changed, 27 insertions, 25 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 4254a9873..b4cf50fd6 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -611,8 +611,8 @@ class CloudController(object): def revoke_security_group_ingress(self, context, group_name=None, group_id=None, **kwargs): if not group_name and not group_id: - err = "Not enough parameters, need group_name or group_id" - raise exception.EC2APIError(_(err)) + err = _("Not enough parameters, need group_name or group_id") + raise exception.EC2APIError(err) self.compute_api.ensure_default_security_group(context) notfound = exception.SecurityGroupNotFound if group_name: @@ -626,8 +626,8 @@ class CloudController(object): if not security_group: raise notfound(security_group_id=group_id) - msg = "Revoke security group ingress %s" - LOG.audit(_(msg), security_group['name'], context=context) + msg = _("Revoke security group ingress %s") + LOG.audit(msg, security_group['name'], context=context) prevalues = [] try: prevalues = kwargs['ip_permissions'] @@ -638,8 +638,8 @@ class CloudController(object): for values in prevalues: rulesvalues = self._rule_args_to_dict(context, values) if not rulesvalues: - err = "%s Not enough parameters to build a valid rule" - raise exception.EC2APIError(_(err % rulesvalues)) + err = _("%s Not enough parameters to build a valid rule") + raise exception.EC2APIError(err % rulesvalues) for values_for_rule in rulesvalues: values_for_rule['parent_group_id'] = security_group.id @@ -665,8 +665,8 @@ class CloudController(object): def authorize_security_group_ingress(self, context, group_name=None, group_id=None, **kwargs): if not group_name and not group_id: - err = "Not enough parameters, need group_name or group_id" - raise exception.EC2APIError(_(err)) + err = _("Not enough parameters, need group_name or group_id") + raise exception.EC2APIError(err) self.compute_api.ensure_default_security_group(context) notfound = exception.SecurityGroupNotFound if group_name: @@ -680,8 +680,8 @@ class CloudController(object): if not security_group: raise notfound(security_group_id=group_id) - msg = "Authorize security group ingress %s" - LOG.audit(_(msg), security_group['name'], context=context) + msg = _("Authorize security group ingress %s") + LOG.audit(msg, security_group['name'], context=context) prevalues = [] try: prevalues = kwargs['ip_permissions'] @@ -691,14 +691,14 @@ class CloudController(object): for values in prevalues: rulesvalues = self._rule_args_to_dict(context, values) if not rulesvalues: - err = "%s Not enough parameters to build a valid rule" - raise exception.EC2APIError(_(err % rulesvalues)) + err = _("%s Not enough parameters to build a valid rule") + raise exception.EC2APIError(err % rulesvalues) for values_for_rule in rulesvalues: values_for_rule['parent_group_id'] = security_group.id if self._security_group_rule_exists(security_group, values_for_rule): - err = '%s - This rule already exists in group' - raise exception.EC2APIError(_(err) % values_for_rule) + err = _('%s - This rule already exists in group') + raise exception.EC2APIError(err % values_for_rule) postvalues.append(values_for_rule) rule_ids = [] @@ -772,8 +772,8 @@ class CloudController(object): def delete_security_group(self, context, group_name=None, group_id=None, **kwargs): if not group_name and not group_id: - err = "Not enough parameters, need group_name or group_id" - raise exception.EC2APIError(_(err)) + err = _("Not enough parameters, need group_name or group_id") + raise exception.EC2APIError(err) notfound = exception.SecurityGroupNotFound if group_name: security_group = db.security_group_get_by_name(context, diff --git a/nova/api/openstack/compute/contrib/disk_config.py b/nova/api/openstack/compute/contrib/disk_config.py index 648fa389b..041686a57 100644 --- a/nova/api/openstack/compute/contrib/disk_config.py +++ b/nova/api/openstack/compute/contrib/disk_config.py @@ -41,7 +41,7 @@ def disk_config_from_api(value): elif value == 'MANUAL': return False else: - msg = _("%s must be either 'MANUAL' or 'AUTO'." % API_DISK_CONFIG) + msg = _("%s must be either 'MANUAL' or 'AUTO'.") % API_DISK_CONFIG raise exc.HTTPBadRequest(explanation=msg) diff --git a/nova/api/openstack/compute/contrib/networks.py b/nova/api/openstack/compute/contrib/networks.py index fc44d1b36..32a4af595 100644 --- a/nova/api/openstack/compute/contrib/networks.py +++ b/nova/api/openstack/compute/contrib/networks.py @@ -67,7 +67,7 @@ class NetworkController(object): def _disassociate(self, request, network_id, body): context = request.environ['nova.context'] authorize(context) - LOG.debug(_("Disassociating network with id %s" % network_id)) + LOG.debug(_("Disassociating network with id %s") % network_id) try: self.network_api.disassociate(context, network_id) except exception.NetworkNotFound: diff --git a/nova/api/openstack/compute/limits.py b/nova/api/openstack/compute/limits.py index a20b75bc9..3245d49d2 100644 --- a/nova/api/openstack/compute/limits.py +++ b/nova/api/openstack/compute/limits.py @@ -137,9 +137,9 @@ class Limit(object): self.water_level = 0 self.capacity = self.unit self.request_value = float(self.capacity) / float(self.value) - self.error_message = _("Only %(value)s %(verb)s request(s) can be " - "made to %(uri)s every %(unit_string)s." % - self.__dict__) + msg = _("Only %(value)s %(verb)s request(s) can be " + "made to %(uri)s every %(unit_string)s.") + self.error_message = msg % self.__dict__ def __call__(self, verb, url): """ diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 02bf0900c..665ee2f26 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -886,7 +886,7 @@ class Resource(wsgi.Application): msg = _("%(url)s returned with HTTP %(status)d") % msg_dict except AttributeError, e: msg_dict = dict(url=request.url, e=e) - msg = _("%(url)s returned a fault: %(e)s" % msg_dict) + msg = _("%(url)s returned a fault: %(e)s") % msg_dict LOG.info(msg) diff --git a/nova/api/validator.py b/nova/api/validator.py index e90918599..f3824075e 100644 --- a/nova/api/validator.py +++ b/nova/api/validator.py @@ -137,8 +137,10 @@ def validate(args, validator): assert callable(f) if not f(args[key]): - msg = "%s with value %s failed validator %s" % ( - key, args[key], f.__name__) - LOG.debug(_(msg)) + value = args[key] + validator = f.__name__ + msg = _("%(key)s with value %(value)s failed validator" + " %(validator)s") + LOG.debug(msg % locals()) return False return True |
