def __init__(self, name, value, type=None, propagated=None, overridable=None, tosubclass=None, toinstance=None, translatable=None): self.name = name self.type = type self.propagated = propagated self.overridable = overridable self.tosubclass = tosubclass self.toinstance = toinstance self.translatable = translatable # Determine type of value if not specified import __builtin__ if type is None: # Can't work out what is going on if type and value are # both not set. if value is None: raise TypeError('Null qualifier "%s" must have a type' % name) if __builtin__.type(value) == list: # Determine type for list value if len(value) == 0: raise TypeError( 'Empty qualifier array "%s" must have a type' % name) self.type = cim_types.cimtype(value[0]) else: # Determine type for regular value self.type = cim_types.cimtype(value) # Don't let anyone set integer or float values. You must use # a subclass from the cim_type module. if __builtin__.type(value) in (int, float, long): raise TypeError('Must use a CIM type for numeric qualifiers.') self.value = value
def __init__(self, name, value, type = None, propagated = None, overridable = None, tosubclass = None, toinstance = None, translatable = None): self.name = name self.type = type self.propagated = propagated self.overridable = overridable self.tosubclass = tosubclass self.toinstance = toinstance self.translatable = translatable # Determine type of value if not specified import __builtin__ if type is None: # Can't work out what is going on if type and value are # both not set. if value is None: raise TypeError('Null qualifier "%s" must have a type' % name) if __builtin__.type(value) == list: # Determine type for list value if len(value) == 0: raise TypeError( 'Empty qualifier array "%s" must have a type' % name) self.type = cim_types.cimtype(value[0]) else: # Determine type for regular value self.type = cim_types.cimtype(value) # Don't let anyone set integer or float values. You must use # a subclass from the cim_type module. if __builtin__.type(value) in (int, float, long): raise TypeError('Must use a CIM type for numeric qualifiers.') self.value = value
def __init__(self, name, value, type=None, class_origin=None, array_size=None, propagated=None, is_array=False, reference_class=None, qualifiers={}, embedded_object=None): # Initialise members self.name = name self.value = value self.type = type self.class_origin = class_origin self.array_size = array_size self.propagated = propagated self.qualifiers = NocaseDict(qualifiers) self.is_array = is_array self.reference_class = reference_class self.embedded_object = embedded_object if isinstance(value, (datetime, timedelta)): value = CIMDateTime(value) import __builtin__ if __builtin__.type(value) == list: self.is_array = True # Determine type of value if not specified if type is None: # Can't work out what is going on if type and value are # both not set. if value is None: raise TypeError('Null property "%s" must have a type' % name) if self.is_array: # Determine type for list value if len(value) == 0: raise TypeError( 'Empty property array "%s" must have a type' % name) elif isinstance(value[0], CIMInstance): self.type = 'string' self.embedded_object = 'instance' elif isinstance(value[0], CIMClass): self.type = 'string' self.embedded_object = 'object' else: self.type = cim_types.cimtype(value[0]) elif isinstance(value, CIMInstanceName): self.type = 'reference' elif isinstance(value, CIMInstance): self.type = 'string' self.embedded_object = 'instance' elif isinstance(value, CIMClass): self.type = 'string' self.embedded_object = 'object' else: # Determine type for regular value self.type = cim_types.cimtype(value)
def __init__(self, name, value, type = None, class_origin = None, array_size = None, propagated = None, is_array = False, reference_class = None, qualifiers = {}, embedded_object = None): # Initialise members self.name = name self.value = value self.type = type self.class_origin = class_origin self.array_size = array_size self.propagated = propagated self.qualifiers = NocaseDict(qualifiers) self.is_array = is_array self.reference_class = reference_class self.embedded_object = embedded_object if isinstance(value, (datetime, timedelta)): value = CIMDateTime(value) import __builtin__ if __builtin__.type(value) == list: self.is_array = True # Determine type of value if not specified if type is None: # Can't work out what is going on if type and value are # both not set. if value is None: raise TypeError('Null property "%s" must have a type' % name) if self.is_array: # Determine type for list value if len(value) == 0: raise TypeError( 'Empty property array "%s" must have a type' % name) elif isinstance(value[0], CIMInstance): self.type = 'string' self.embedded_object = 'instance' elif isinstance(value[0], CIMClass): self.type = 'string' self.embedded_object = 'object' else: self.type = cim_types.cimtype(value[0]) elif isinstance(value, CIMInstanceName): self.type = 'reference' elif isinstance(value, CIMInstance): self.type = 'string' self.embedded_object = 'instance' elif isinstance(value, CIMClass): self.type = 'string' self.embedded_object = 'object' else: # Determine type for regular value self.type = cim_types.cimtype(value)