From ab3eabe7d329dd5664ebd27d91def73e6d9c09f4 Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 18 Jun 2024 14:28:56 +0200 Subject: [PATCH] Cast file size as an actual Decimal, not a float --- ckanext/dcat/profiles/euro_dcat_ap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ckanext/dcat/profiles/euro_dcat_ap.py b/ckanext/dcat/profiles/euro_dcat_ap.py index b7e4cae4..b0057110 100644 --- a/ckanext/dcat/profiles/euro_dcat_ap.py +++ b/ckanext/dcat/profiles/euro_dcat_ap.py @@ -1,4 +1,5 @@ import json +from decimal import Decimal, DecimalException from rdflib import term, URIRef, BNode, Literal import ckantoolkit as toolkit @@ -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"):