Ejemplo n.º 1
0
 def asThing(
     self,
     t_created: datetime.datetime,
     status: int,
     resolved_url: str,
     t_resolved: datetime.datetime,
     resolve_elapsed: float,
     media_type: str = None,
 ) -> Thing:
     L = getLogger()
     L.debug("SESARItem.asThing")
     # Note: SESAR incorrectly returns "application/json;charset=UTF-8" for json-ld content
     if media_type is None:
         media_type = MEDIA_JSON_LD
     _thing = Thing(
         id=self.identifier,
         tcreated=t_created,
         item_type=None,
         authority_id=SESARItem.AUTHORITY_ID,
         resolved_url=resolved_url,
         resolved_status=status,
         tresolved=t_resolved,
         resolve_elapsed=resolve_elapsed,
     )
     if not isinstance(self.item, dict):
         L.error("Item is not an object")
         return _thing
     _thing.item_type = self.getItemType()
     _thing.resolved_media_type = media_type
     _thing.resolve_elapsed = resolve_elapsed
     _thing.resolved_content = self.item
     return _thing
Ejemplo n.º 2
0
 def as_thing(
     self,
     t_created: datetime.datetime,
     status: int,
     source_file_path: str,
     t_resolved: datetime.datetime,
 ) -> Thing:
     logging.debug("SmithsonianItem.asThing")
     _thing = Thing(
         id=self.identifier,
         tcreated=t_created,
         item_type=None,
         authority_id=SmithsonianItem.AUTHORITY_ID,
         resolved_url=f"file://{source_file_path}",
         resolved_status=status,
         tresolved=t_resolved,
         resolve_elapsed=0,
     )
     if not isinstance(self.source_item, dict):
         L.error("Item is not an object")
         return _thing
     _thing.item_type = "sample"
     _thing.resolved_media_type = SmithsonianItem.TEXT_CSV
     # Note that this field doesn't make sense for Smithsonian as the information is coming from a local file
     # _thing.resolve_elapsed = resolve_elapsed
     _thing.resolved_content = self.source_item
     return _thing