Merge "Add i18n support for error message"
This commit is contained in:
commit
e829724747
|
@ -19,6 +19,8 @@ from oslo_config import cfg
|
|||
from oslo_db import api as db_api
|
||||
import six
|
||||
|
||||
from cloudkitty.i18n import _
|
||||
|
||||
_BACKEND_MAPPING = {'sqlalchemy': 'cloudkitty.rating.hash.db.sqlalchemy.api'}
|
||||
IMPL = db_api.DBAPI.from_config(cfg.CONF,
|
||||
backend_mapping=_BACKEND_MAPPING,
|
||||
|
@ -43,7 +45,8 @@ class NoSuchService(ClientHashMapError):
|
|||
|
||||
def __init__(self, name=None, uuid=None):
|
||||
super(NoSuchService, self).__init__(
|
||||
"No such service: %s (UUID: %s)" % (name, uuid))
|
||||
_("No such service: %(name)s (UUID: %(uuid)s)") % {'name': name,
|
||||
'uuid': uuid})
|
||||
self.name = name
|
||||
self.uuid = uuid
|
||||
|
||||
|
@ -53,7 +56,7 @@ class NoSuchField(ClientHashMapError):
|
|||
|
||||
def __init__(self, uuid):
|
||||
super(NoSuchField, self).__init__(
|
||||
"No such field: %s" % uuid)
|
||||
_("No such field: %s") % uuid)
|
||||
self.uuid = uuid
|
||||
|
||||
|
||||
|
@ -62,7 +65,8 @@ class NoSuchGroup(ClientHashMapError):
|
|||
|
||||
def __init__(self, name=None, uuid=None):
|
||||
super(NoSuchGroup, self).__init__(
|
||||
"No such group: %s (UUID: %s)" % (name, uuid))
|
||||
_("No such group: %(name)s (UUID: %(uuid)s)") %
|
||||
{'name': name, 'uuid': uuid})
|
||||
self.name = name
|
||||
self.uuid = uuid
|
||||
|
||||
|
@ -71,7 +75,7 @@ class NoSuchMapping(ClientHashMapError):
|
|||
"""Raised when the mapping doesn't exist."""
|
||||
|
||||
def __init__(self, uuid):
|
||||
msg = ("No such mapping: %s" % uuid)
|
||||
msg = (_("No such mapping: %s") % uuid)
|
||||
super(NoSuchMapping, self).__init__(msg)
|
||||
self.uuid = uuid
|
||||
|
||||
|
@ -80,7 +84,7 @@ class NoSuchThreshold(ClientHashMapError):
|
|||
"""Raised when the threshold doesn't exist."""
|
||||
|
||||
def __init__(self, uuid):
|
||||
msg = ("No such threshold: %s" % uuid)
|
||||
msg = (_("No such threshold: %s") % uuid)
|
||||
super(NoSuchThreshold, self).__init__(msg)
|
||||
self.uuid = uuid
|
||||
|
||||
|
@ -89,8 +93,7 @@ class NoSuchType(ClientHashMapError):
|
|||
"""Raised when a mapping type is not handled."""
|
||||
|
||||
def __init__(self, map_type):
|
||||
msg = ("No mapping type: %s"
|
||||
% (map_type))
|
||||
msg = (_("No mapping type: %s") % map_type)
|
||||
super(NoSuchType, self).__init__(msg)
|
||||
self.map_type = map_type
|
||||
|
||||
|
@ -100,7 +103,8 @@ class ServiceAlreadyExists(ClientHashMapError):
|
|||
|
||||
def __init__(self, name, uuid):
|
||||
super(ServiceAlreadyExists, self).__init__(
|
||||
"Service %s already exists (UUID: %s)" % (name, uuid))
|
||||
_("Service %(name)s already exists (UUID: %(uuid)s)") %
|
||||
{'name': name, 'uuid': uuid})
|
||||
self.name = name
|
||||
self.uuid = uuid
|
||||
|
||||
|
@ -110,7 +114,8 @@ class FieldAlreadyExists(ClientHashMapError):
|
|||
|
||||
def __init__(self, field, uuid):
|
||||
super(FieldAlreadyExists, self).__init__(
|
||||
"Field %s already exists (UUID: %s)" % (field, uuid))
|
||||
_("Field %(field)s already exists (UUID: %(uuid)s)") %
|
||||
{'field': field, 'uuid': uuid})
|
||||
self.field = field
|
||||
self.uuid = uuid
|
||||
|
||||
|
@ -120,7 +125,8 @@ class GroupAlreadyExists(ClientHashMapError):
|
|||
|
||||
def __init__(self, name, uuid):
|
||||
super(GroupAlreadyExists, self).__init__(
|
||||
"Group %s already exists (UUID: %s)" % (name, uuid))
|
||||
_("Group %(name)s already exists (UUID: %(uuid)s)") %
|
||||
{'name': name, 'uuid': uuid})
|
||||
self.name = name
|
||||
self.uuid = uuid
|
||||
|
||||
|
@ -137,8 +143,10 @@ class MappingAlreadyExists(ClientHashMapError):
|
|||
# TODO(sheeprine): UUID is deprecated
|
||||
parent_id = parent_id if parent_id else uuid
|
||||
super(MappingAlreadyExists, self).__init__(
|
||||
"Mapping '%s' already exists for %s '%s', tenant: '%s'"
|
||||
% (mapping, parent_type, parent_id, tenant_id))
|
||||
_("Mapping '%(mapping)s' already exists for %(p_type)s '%(p_id)s',"
|
||||
" tenant: '%(t_id)s'") %
|
||||
{'mapping': mapping, 'p_type': parent_type,
|
||||
'p_id': parent_id, 't_id': tenant_id})
|
||||
self.mapping = mapping
|
||||
self.uuid = parent_id
|
||||
self.parent_id = parent_id
|
||||
|
@ -158,8 +166,10 @@ class ThresholdAlreadyExists(ClientHashMapError):
|
|||
# TODO(sheeprine): UUID is deprecated
|
||||
parent_id = parent_id if parent_id else uuid
|
||||
super(ThresholdAlreadyExists, self).__init__(
|
||||
"Threshold '%s' already exists for %s '%s', tenant: '%s'"
|
||||
% (threshold, parent_type, parent_id, tenant_id))
|
||||
_("Threshold '%(threshold)s' already exists for %(p_type)s "
|
||||
"'%(p_id)s', tenant: '%(t_id)s'") %
|
||||
{'threshold': threshold, 'p_type': parent_type,
|
||||
'p_id': parent_id, 't_id': tenant_id})
|
||||
self.threshold = threshold
|
||||
self.uuid = parent_id
|
||||
self.parent_id = parent_id
|
||||
|
@ -172,7 +182,7 @@ class MappingHasNoGroup(ClientHashMapError):
|
|||
|
||||
def __init__(self, uuid):
|
||||
super(MappingHasNoGroup, self).__init__(
|
||||
"Mapping has no group (UUID: %s)" % uuid)
|
||||
_("Mapping has no group (UUID: %s)") % uuid)
|
||||
self.uuid = uuid
|
||||
|
||||
|
||||
|
@ -181,7 +191,7 @@ class ThresholdHasNoGroup(ClientHashMapError):
|
|||
|
||||
def __init__(self, uuid):
|
||||
super(ThresholdHasNoGroup, self).__init__(
|
||||
"Threshold has no group (UUID: %s)" % uuid)
|
||||
_("Threshold has no group (UUID: %s)") % uuid)
|
||||
self.uuid = uuid
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ from oslo_config import cfg
|
|||
from oslo_db import api as db_api
|
||||
import six
|
||||
|
||||
from cloudkitty.i18n import _
|
||||
|
||||
_BACKEND_MAPPING = {
|
||||
'sqlalchemy': 'cloudkitty.rating.pyscripts.db.sqlalchemy.api'}
|
||||
IMPL = db_api.DBAPI.from_config(cfg.CONF,
|
||||
|
@ -36,7 +38,8 @@ class NoSuchScript(Exception):
|
|||
|
||||
def __init__(self, name=None, uuid=None):
|
||||
super(NoSuchScript, self).__init__(
|
||||
"No such script: %s (UUID: %s)" % (name, uuid))
|
||||
_("No such script: %(name)s (UUID: %(uuid)s)") % {'name': name,
|
||||
'uuid': uuid})
|
||||
self.name = name
|
||||
self.uuid = uuid
|
||||
|
||||
|
@ -46,7 +49,8 @@ class ScriptAlreadyExists(Exception):
|
|||
|
||||
def __init__(self, name, uuid):
|
||||
super(ScriptAlreadyExists, self).__init__(
|
||||
"Script %s already exists (UUID: %s)" % (name, uuid))
|
||||
_("Script %(name)s already exists (UUID: %(uuid)s)") %
|
||||
{'name': name, 'uuid': uuid})
|
||||
self.name = name
|
||||
self.uuid = uuid
|
||||
|
||||
|
|
Loading…
Reference in New Issue