-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Add a convenience method (or a set of them probably) that will add file info to each Item Asset (size, checksum, or whatever other fields from the STAC file info extension).
Suggested starting point (thank you @pjhartzell):
@staticmethod
def sha256sum_multihash(path: Path) -> str:
with path.open('rb') as f:
return str(
multihash.wrap(
hashlib.file_digest(f, 'sha256').digest(),
'sha2-256',
).hex(),
)
def _add_fileinfo_to_assets(self, item: pystac.Item) -> None:
for asset in item.assets.values():
fext = FileExtension.ext(
asset,
add_if_missing=True,
)
path = Path(asset.href)
if fext.checksum is None:
fext.checksum = self.sha256sum_multihash(path)
if fext.size is None:
fext.size = path.stat().st_size
Metadata
Metadata
Assignees
Labels
No labels