示例#1
0
def equals_pb(left: Asset, right: Asset):
    """
does the AssetWrap equal a protobuf Asset
    :param other:
    :return:
    """
    return left.SerializeToString() == right.SerializeToString()
 def __deepcopy__(self, memo):
     cls = self.__class__
     result = cls.__new__(cls)
     memo[id(self)] = result
     for k, v in self.__dict__.items():
         if k == '_asset':
             value = Asset()
             value.CopyFrom(v)
             setattr(result, k, value)
         else:
             setattr(result, k, deepcopy(v))
     return result
    def equals_pb(self, other: Asset):
        """
does the AssetWrap equal a protobuf Asset
        :param other:
        :return:
        """
        return self._asset.SerializeToString() == other.SerializeToString()
    def __init__(self,
                 asset: Asset = None,
                 bucket: str = None,
                 object_path: str = None,
                 asset_type: enum.AssetType = enum.AssetType.UNKNOWN_ASSET,
                 eo_bands: enum.Band = enum.Band.UNKNOWN_BAND,
                 href="",
                 cloud_platform: enum.CloudPlatform = enum.CloudPlatform.
                 UNKNOWN_CLOUD_PLATFORM,
                 bucket_manager: str = "",
                 bucket_region: str = "",
                 key_suffix: str = "",
                 asset_key: str = ""):
        self._asset_key = asset_key
        if asset is None:
            asset = Asset(href=href,
                          eo_bands=eo_bands,
                          asset_type=asset_type,
                          cloud_platform=cloud_platform,
                          bucket_manager=bucket_manager,
                          bucket_region=bucket_region,
                          bucket=bucket,
                          object_path=object_path)

        self._asset = asset

        if self._asset.bucket is None or self._asset.object_path is None:
            raise ValueError(
                "bucket and object path must be set in valid asset")

        self._ext = pathlib.Path(self._asset.object_path).suffix

        b_thumbnail_png = self._asset.asset_type == enum.AssetType.THUMBNAIL and self._ext == '.png'
        _, href_type = self._asset_type_details(
            asset_type=self._asset.asset_type, b_thumbnail_png=b_thumbnail_png)
        self._asset.type = href_type
        self._type = href_type
        self._key_suffix = key_suffix
示例#5
0
 def test_has_asset(self):
     stac_id = "LO81120152015061LGN00"
     stac_request = StacRequest(id=stac_id)
     stac_item = client.search_one(stac_request=stac_request)
     for key in stac_item.assets:
         asset = stac_item.assets[key]
         self.assertTrue(utils.has_asset(stac_item, asset))
         garbage = Asset(href="pie")
         self.assertFalse(utils.has_asset(stac_item, garbage))
         garbage.asset_type = asset.asset_type
         self.assertFalse(utils.has_asset(stac_item, garbage))
         garbage.href = asset.href
         garbage.bucket = asset.bucket
         garbage.type = asset.type
         garbage.eo_bands = asset.eo_bands
         garbage.cloud_platform = asset.cloud_platform
         garbage.bucket_manager = asset.bucket_manager
         garbage.bucket_region = asset.bucket_region
         garbage.object_path = asset.object_path
         self.assertTrue(utils.has_asset(stac_item, garbage))
示例#6
0
 def test_asset_match(self):
     asset_1 = Asset(href="pecans")
     asset_2 = Asset(href="walnuts")
     stac_item = StacItem()
     stac_item.assets["test_key"].CopyFrom(asset_1)
     self.assertFalse(utils.has_asset(stac_item, asset_2))