def get_schema(itemtype): item = caching.get_schema(itemtype) if item is not None: return item item = get_schema_set()['types'][itemtype] if 'plural_label' not in item: if item['label'][-2:] in ['ay', 'ey', 'iy', 'oy', 'uy', 'wy']: item['plural_label'] = u'%ss' % item['label'] elif item['label'].endswith('y'): item['plural_label'] = u'%sies' % item['label'][:-1] elif item['label'].endswith('s') or item['label'].endswith('o'): item['plural_label'] = u'%ses' % item['label'] else: item['plural_label'] = u'%ss' % item['label'] # inherit properties of supertypes if 'properties' not in item: item['properties'] = [] for stype in item['supertypes']: item['properties'] += get_schema(stype)['properties'] item['properties'] = list(set(item['properties'])) # remove legacy spellings legacy_spellings = get_legacy_spellings() props = set(item['properties']).difference(legacy_spellings) sprops = set(item['specific_properties']).difference(legacy_spellings) # merge specific_properties into properties item['properties'] = sorted(list(props.union(sprops))) item['specific_properties'] = sorted(list(sprops)) caching.set_schema(itemtype, item) return item
def get_schema(itemtype, self_contained=False): if self_contained: return get_sc_schema(itemtype) item = caching.get_schema(itemtype) if item is not None: return item item = get_schema_set()["types"][itemtype] if "plural_label" not in item: if item["label"][-2:] in ["ay", "ey", "iy", "oy", "uy", "wy"]: item["plural_label"] = u"%ss" % item["label"] elif item["label"].endswith("y"): item["plural_label"] = u"%sies" % item["label"][:-1] elif item["label"].endswith("s") or item["label"].endswith("o"): item["plural_label"] = u"%ses" % item["label"] else: item["plural_label"] = u"%ss" % item["label"] # inherit properties of supertypes if "properties" not in item: item["properties"] = [] for stype in item["supertypes"]: item["properties"] += get_schema(stype)["properties"] item["properties"] = list(set(item["properties"])) # remove legacy spellings legacy_spellings = get_legacy_spellings() props = set(item["properties"]).difference(legacy_spellings) sprops = set(item["specific_properties"]).difference(legacy_spellings) # merge specific_properties into properties item["properties"] = sorted(list(props.union(sprops))) item["specific_properties"] = sorted(list(sprops)) caching.set_schema(itemtype, item) return item
def get_schema(itemtype, self_contained=False): if self_contained: return get_sc_schema(itemtype) item = caching.get_schema(itemtype) if item is not None: return item item = get_schema_set()['types'][itemtype] # populate missing fields if 'url' not in item: item['url'] = '/sp.schema/types/%s' % itemtype if 'id' not in item: item['id'] = itemtype if 'label' not in item: item['label'] = item['id'] if 'comment' not in item: item['comment'] = item['label'] if 'comment_plain' not in item: item['comment_plain'] = item['comment'] if 'subtypes' not in item: item['subtypes'] = [] if 'ancestors' not in item: # collect ancestors ancestors = [] parent = item while len(parent['supertypes']) > 0: parent_itemtype = parent['supertypes'][0] ancestors.append(parent_itemtype) parent = get_schema(parent_itemtype) ancestors.reverse() item['ancestors'] = ancestors if 'plural_label' not in item: if item['label'][-2:] in ['ay', 'ey', 'iy', 'oy', 'uy', 'wy']: item['plural_label'] = u'%ss' % item['label'] elif item['label'].endswith('y'): item['plural_label'] = u'%sies' % item['label'][:-1] elif item['label'].endswith('s') or item['label'].endswith('o'): item['plural_label'] = u'%ses' % item['label'] else: item['plural_label'] = u'%ss' % item['label'] # inherit properties of supertypes if 'properties' not in item: item['properties'] = [] for stype in item['supertypes']: super_props = [p for p in get_schema(stype)['properties'] if p not in item['properties']] item['properties'] += super_props # remove legacy spellings legacy_spellings = set(get_legacy_spellings()) item['properties'] = [p for p in item['properties'] if p not in legacy_spellings] sprops = set(item['specific_properties']).difference(legacy_spellings) # merge specific_properties into properties item['properties'] += [p for p in sprops if p not in item['properties']] item['specific_properties'] = list(sprops) caching.set_schema(itemtype, item) return item
def get_schema(itemtype, self_contained=False): if self_contained: return get_sc_schema(itemtype) item = caching.get_schema(itemtype) if item is not None: return item item = get_schema_set()['types'][itemtype] # populate missing fields if 'url' not in item: item['url'] = '/sp.schema/types/%s' % itemtype if 'id' not in item: item['id'] = itemtype if 'label' not in item: item['label'] = item['id'] if 'comment' not in item: item['comment'] = item['label'] if 'comment_plain' not in item: item['comment_plain'] = item['comment'] if 'subtypes' not in item: item['subtypes'] = [] if 'ancestors' not in item: # collect ancestors ancestors = [] parent = item while len(parent['supertypes']) > 0: parent_itemtype = parent['supertypes'][0] ancestors.append(parent_itemtype) parent = get_schema(parent_itemtype) ancestors.reverse() item['ancestors'] = ancestors if 'plural_label' not in item: if item['label'][-2:] in ['ay', 'ey', 'iy', 'oy', 'uy', 'wy']: item['plural_label'] = u'%ss' % item['label'] elif item['label'].endswith('y'): item['plural_label'] = u'%sies' % item['label'][:-1] elif item['label'].endswith('s') or item['label'].endswith('o'): item['plural_label'] = u'%ses' % item['label'] else: item['plural_label'] = u'%ss' % item['label'] # inherit properties of supertypes if 'properties' not in item: item['properties'] = [] for stype in item['supertypes']: super_props = [ p for p in get_schema(stype)['properties'] if p not in item['properties'] ] item['properties'] += super_props # remove legacy spellings legacy_spellings = set(get_legacy_spellings()) item['properties'] = [ p for p in item['properties'] if p not in legacy_spellings ] sprops = set(item['specific_properties']).difference(legacy_spellings) # merge specific_properties into properties and sort item['properties'] += [p for p in sprops if p not in item['properties']] item['properties'] = sorted(item['properties']) item['specific_properties'] = list(sprops) caching.set_schema(itemtype, item) return item