Exemplo n.º 1
0
 def ValidateDimensionAndValue(self, dim_name, dim_value):
     """Validates that a matrix dimension has a valid name and value."""
     if dim_name == _MODEL_DIMENSION:
         if dim_value not in self._model_ids:
             raise exceptions.ModelNotFoundError(dim_value)
     elif dim_name == _VERSION_DIMENSION:
         if dim_value not in self._version_ids:
             raise exceptions.VersionNotFoundError(dim_value)
     elif dim_name == _LOCALE_DIMENSION:
         if dim_value not in self._locale_ids:
             raise exceptions.LocaleNotFoundError(dim_value)
     elif dim_name == _ORIENTATION_DIMENSION:
         if dim_value not in self._orientation_ids:
             raise exceptions.OrientationNotFoundError(dim_value)
     else:
         raise exceptions.InvalidDimensionNameError(dim_name)
     return dim_value
Exemplo n.º 2
0
 def ValidateDimensionAndValue(self, dim_name, dim_value):
     """Validates that a matrix dimension has a valid name and value."""
     if dim_name == 'model':
         if dim_value not in self._model_ids:
             raise exceptions.ModelNotFoundError(dim_value)
     elif dim_name == 'locale':
         if dim_value not in self._locale_ids:
             raise exceptions.LocaleNotFoundError(dim_value)
     elif dim_name == 'orientation':
         if dim_value not in self._orientation_ids:
             raise exceptions.OrientationNotFoundError(dim_value)
     elif dim_name == 'version':
         if dim_value not in self._version_ids:
             # Users are allowed to specify either version name or version ID.
             version_id = self._version_name_to_id.get(dim_value, None)
             if not version_id:
                 raise exceptions.VersionNotFoundError(dim_value)
             return version_id
     else:
         raise exceptions.InvalidDimensionNameError(dim_name)
     return dim_value