Coverage for ion/core/object/cdm_methods/attribute : 61.90%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#!/usr/bin/env python @file ion/core/object/cdm_methods/attribute.py @brief Wrapper methods for the cdm attribute object @author David Stuebe @author Tim LaRocque TODO: """
# Get the object decorator used on wrapper methods!
#---------------------------------------# # Wrapper_Attribute Specialized Methods # #---------------------------------------# """ Specialized method for CDM Objects to find an attribute value by its index """ raise OOIObjectError('Invalid array index requested: "%s"' % str(index)) # @todo: determine if you can have an empty array -- if so, check for empty here raise OOIObjectError('Given array index out of bounds: %i -- valid range: 0 to %i' % (int(index), len(self.array.value) - 1))
else:
def _get_attribute_values(self): """ Specialized method for CDM Objects to retreive all attribute values as a string list """ # Create a copy of the values array else:
def _get_attribute_values_length(self): """ Specialized method for CDM Objects to find the length of an attribute object's values """
def _get_attribute_data_type(self): """ Specialized method for CDM Objects to retrieve the attribute data_type as a long. This value can be used to compare equality with other attributes' data_types """
def _attribute_is_same_type(self, attribute): if not hasattr(attribute, 'GetDataType'): raise TypeError('The datatype of the given attribute cannot be found.: Please specify an instance of "%s". Recieved "%s"' % (type(self), type(attribute)))
return self.GetDataType() == attribute.GetDataType()
except UnicodeEncodeError: try: return text.decode('latin-1') # Windows
except UnicodeEncodeError:
try: return text.decode('mac-roman') # Mac
except UnicodeEncodeError: return text.decode('iso-8859-1') # iso 8859
except Exception, uee:
log.warn('Sanitizing attribute character encoding failed!!!!\n%s' % str(uee)) return '*** Unknown character encoding in attribute string ***' |