Skip to content

Commit

Permalink
reportIdentifier now sha512 of subset
Browse files Browse the repository at this point in the history
  • Loading branch information
david-i-berry committed Nov 21, 2024
1 parent dbc0293 commit 19b8a66
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bufr2geojson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,14 +1142,22 @@ def transform(data: bytes, guess_wsi: bool = False,
LOGGER.info(f"{nsubsets} subsets")

for idx in range(nsubsets):
reportIdentifier = uuid.uuid4()
# reportIdentifier = None
if nsubsets > 1: # noqa this is only required if more than one subset (and will crash if only 1)
LOGGER.debug(f"Extracting subset {idx+1} of {nsubsets}")
codes_set(bufr_handle, "extractSubset", idx+1)
codes_set(bufr_handle, "doExtractSubsets", 1)
LOGGER.debug("Cloning subset to new message")

single_subset = codes_clone(bufr_handle)

with BytesIO() as bufr_bytes:
codes_write(single_subset, bufr_bytes)
bufr_bytes.seek(0)
sha512 = hashlib.sha512()
sha512.update(bufr_bytes.getvalue())
reportIdentifier = sha512.hexdigest()

LOGGER.debug("Unpacking")
codes_set(single_subset, "unpack", True)

Expand Down

0 comments on commit 19b8a66

Please sign in to comment.