def get_values_representation(self, fields=None, internal=False): vals = {} id_attribute = self.id_attribute for attr in self.attributes: a_name = attr.name if (fields is None or a_name == id_attribute or a_name in fields) \ and (internal or attr.accesstype is not None): val = getattr(self, "_" + a_name, None) if val is None: continue if isinstance(attr, ListAttribute): # TODO: return simple values. No representation if attr.content_type is AnyURI: # any uri list vals[a_name] = {"reference": val} elif issubclass(attr.content_type, Entity): # complex list vals[a_name] = { a_name: [x.get_values_representation() for x in val] } else: # simple list vals[a_name] = {a_name[:-1]: val} elif isinstance(attr, EntityAttribute): vals[a_name] = val.values else: try: val = val.isoformat() except AttributeError: pass vals[a_name] = val return vals
def get_etsi_types(): global _all_types if _all_types is None: _all_types = [ x for x in globals().values() if issubclass(x, ETSIResource) and not x.__subclasses__() ] return _all_types
def convert_content(self, value, instance): if isinstance(value, self.content_type): return value if issubclass(self.content_type, Entity): if isinstance(value, Mapping): return self._convert_mapping(value, instance) raise ValueError( "Illegal value for sequence '%s' (%s): %s (%s)" % (self.name, self.content_type, value, type(value))) return self.content_type(value)
def __init__(self, type, virtual=False, default=NOT_SET, *args, **kw): if type and not issubclass(type, Resource): raise TypeError(type) super(SubresourceMember, self).__init__(type=type, *args, **kw)
"responseStatusCode": "rsc" } short_to_long_parameter_mapping = {v: k for k, v in long_to_short_parameter_mapping.items()} def get_long_parameter_name(n): return short_to_long_parameter_mapping.get(n) def get_short_parameter_name(n): return long_to_short_parameter_mapping.get(n) _all_types = {k: v for k, v in globals().items() if issubclass(v, OneM2MEntity) and not v.__subclasses__()} _all_types_short = {} _all_types_long = {} for k, v in _all_types.items(): if get_short_resource_name(k): long_name = k short_name = get_short_resource_name(k) elif get_short_attribute_name(k): long_name = k short_name = get_short_attribute_name(k) elif get_short_member_name(k): long_name = k short_name = get_short_member_name(k) elif get_short_root_name(k):
for k, v in long_to_short_parameter_mapping.items() } def get_long_parameter_name(n): return short_to_long_parameter_mapping.get(n) def get_short_parameter_name(n): return long_to_short_parameter_mapping.get(n) _all_types = { k: v for k, v in globals().iteritems() if issubclass(v, OneM2MEntity) and not v.__subclasses__() } _all_types_short = {} _all_types_long = {} for k, v in _all_types.iteritems(): if get_short_resource_name(k): long_name = k short_name = get_short_resource_name(k) elif get_short_attribute_name(k): long_name = k short_name = get_short_attribute_name(k) elif get_short_member_name(k): long_name = k short_name = get_short_member_name(k)