def _get_collection_type_id(self, coll_type, subtypes, element_names=None): if coll_type == 'tuple' and not subtypes: return s_obj.get_known_type_id('empty-tuple') subtypes = (f"{st}" for st in subtypes) string_id = f'{coll_type}\x00{":".join(subtypes)}' if element_names: string_id += f'\x00{":".join(element_names)}' return uuidgen.uuid5(s_types.TYPE_ID_NAMESPACE, string_id)
def _get_id(cls, data): if data['collection'] == 'tuple' and not data['subtypes']: return s_obj.get_known_type_id('empty-tuple') if data['name'] == 'anytype': return s_obj.get_known_type_id('anytype') # A type desc node is uniquely identified by it's type, # and the name and position within a parent type. id_str = f"{data['maintype']!r}::{data['name']!r}::{data['position']}" return uuidgen.uuid5(s_types.TYPE_ID_NAMESPACE, id_str)
def _get_object_type_id(self, coll_type, subtypes, element_names=None, *, links_props=None, links=None, has_implicit_fields=False): subtypes = (f"{st}" for st in subtypes) string_id = f'{coll_type}\x00{":".join(subtypes)}' if element_names: string_id += f'\x00{":".join(element_names)}' string_id += f'{has_implicit_fields!r};{links_props!r};{links!r}' return uuidgen.uuid5(s_types.TYPE_ID_NAMESPACE, string_id)
def _get_union_type_id(self, union_type): base_type_id = ','.join( str(c.id) for c in union_type.children(self.schema)) return uuidgen.uuid5(s_types.TYPE_ID_NAMESPACE, base_type_id)
def _get_set_type_id(cls, basetype_id): return uuidgen.uuid5(s_types.TYPE_ID_NAMESPACE, 'set-of::' + str(basetype_id))