def include(self, new_value): if self._link is not None: raise TypeError("%s.include: You can either set link or include, but not both." % repr(self)) if not new_value: self._include = None self.clean() return if '#' in new_value: url, path = new_value.split('#', 1) else: url, path = new_value, None terminology.deferred_load(url) if self.parent is None: self._include = new_value return term = terminology.load(url) new_section = term.get_section_by_path(path) if path is not None else term.sections[0] if self._include is not None: self.clean() self._include = new_value self.merge(new_section)
def include(self, new_value): if self._link is not None: raise TypeError( "%s.include: You can either set link or include, but not both." % repr(self)) if not new_value: self._include = None self.clean() return if '#' in new_value: url, path = new_value.split('#', 1) else: url, path = new_value, None terminology.deferred_load(url) if self.parent is None: self._include = new_value return term = terminology.load(url) new_section = term.get_section_by_path( path) if path is not None else term.sections[0] if self._include is not None: self.clean() self._include = new_value self.merge(new_section)
def get_mapping_object(url): """ returns the object instance a mapping-url points to """ url, stype, prop_name = mapable.parse_mapping(url) term = terminology.load(url) if term is None: raise MappingError("Terminology '%s' could not be loaded" % url) if stype is None: return term.sections[0] sec = term.find_related(type=stype) if sec is None: raise MappingError("No section of type '%s' could be found" % stype) if prop_name is None: return sec try: return sec.properties[prop_name] except KeyError: raise MappingError("No property named '%s' could be found in section '%s'" % (prop_name, sec.name))
def get_mapping_object(url): """ returns the object instance a mapping-url points to """ url, stype, prop_name = mapable.parse_mapping(url) term = terminology.load(url) if term is None: raise MappingError("Terminology '%s' could not be loaded" % url) if stype is None: return term.sections[0] sec = term.find_related(type=stype) if sec is None: raise MappingError("No section of type '%s' could be found" % stype) if prop_name is None: return sec try: return sec.properties[prop_name] except KeyError: raise MappingError( "No property named '%s' could be found in section '%s'" % (prop_name, sec.name))
def get_terminology_equivalent(self): repo = self.get_repository() if repo is None: return None term = terminology.load(repo) if term is None: return None return term.find_related(type=self.type)
def get_terminology_equivalent(self): if self.repository is None: return None term = terminology.load(self.repository) return term