コード例 #1
0
 def _GetUnitValue(self, kind, unit):
     """Returns the integer unit suffix and value for unit."""
     if self._type_abbr:
         unit = scaled_integer.DeleteTypeAbbr(unit)
     try:
         return unit, scaled_integer.GetUnitSize(unit)
     except ValueError as e:
         raise exceptions.ConstraintError(self.name, kind, unit,
                                          _SubException(e) + '.')
コード例 #2
0
 def _ConvertEndpoint(self, endpoint, kind):
     """Declaration time endpoint conversion check."""
     message = None
     try:
         endpoint.value = self._convert_endpoint(endpoint.string)
         return
     except exceptions.ParseError as e:
         message = six.text_type(e).split('. ', 1)[1].rstrip('.')
     except (AttributeError, ValueError) as e:
         message = _SubException(e)
     raise exceptions.ConstraintError(self.GetPresentationName(), kind,
                                      endpoint.string, message + '.')