Exemplo n.º 1
0
 def triples_generated(self):
     context = rdflib.Namespace(
         f'https://apinatomy.org/uris/models/{self.id}/ids/')
     for cls in [Node, Link, Lyph, Tree, Group, Material]:
         if cls.key in self.blob:
             # FIXME trees not in all blobs
             for blob in self.blob[cls.key]:
                 try:
                     yield from cls(blob, context).triples()
                 except NoIdError as e:
                     logd.exception(e)
Exemplo n.º 2
0
    def lift(data, lifts, source_key_optional=True):
        """ 
        lifts are lists with the following structure
        [[path, function], ...]

        the only difference from derives is that lift
        overwrites the underlying data (e.g. a filepath
        would be replaced by the contents of the file)

        """

        for path, function in lifts:
            try:
                old_value = adops.get(data, path)
            except exc.NoSourcePathError as e:
                if source_key_optional:
                    logd.exception(str(type(e)))
                    continue
                else:
                    raise e

            new_value = function(old_value)
            adops.add(data, path, new_value, fail_on_exists=False)