Skip to content

Commit

Permalink
Cast file size as an actual Decimal, not a float
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Jun 18, 2024
1 parent d7c9597 commit ab3eabe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ckanext/dcat/profiles/euro_dcat_ap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from decimal import Decimal, DecimalException

from rdflib import term, URIRef, BNode, Literal
import ckantoolkit as toolkit
Expand Down Expand Up @@ -545,10 +546,10 @@ def graph_from_dataset(self, dataset_dict, dataset_ref):
(
distribution,
DCAT.byteSize,
Literal(float(resource_dict["size"]), datatype=XSD.decimal),
Literal(Decimal(resource_dict["size"]), datatype=XSD.decimal),
)
)
except (ValueError, TypeError):
except (ValueError, TypeError, DecimalException):
g.add((distribution, DCAT.byteSize, Literal(resource_dict["size"])))
# Checksum
if resource_dict.get("hash"):
Expand Down

0 comments on commit ab3eabe

Please sign in to comment.