From e8aba8ea6e260d2bec579e320df12a36d6efd0c8 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 6 Apr 2023 18:15:06 -0400 Subject: [PATCH] ENH: use sanitize_value helper instead of adhoc replacement of _ This seems to Closes #172 as well --- dandischema/metadata.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dandischema/metadata.py b/dandischema/metadata.py index b1f4134..5d5ff33 100644 --- a/dandischema/metadata.py +++ b/dandischema/metadata.py @@ -15,7 +15,7 @@ ) from .exceptions import JsonschemaValidationError, PydanticValidationError from . import models -from .utils import _ensure_newline, version2tuple +from .utils import _ensure_newline, sanitize_value, version2tuple schema_map = { "Dandiset": "dandiset.json", @@ -255,7 +255,7 @@ def migrate( def _get_samples(value: dict, stats: _stats_type, hierarchy: Any) -> _stats_type: if "sampleType" in value: sampletype = value["sampleType"]["name"] - obj = value["identifier"].replace("_", "-") + obj = sanitize_value(value["identifier"]) if obj not in stats[sampletype]: stats[sampletype].append(obj) if "wasDerivedFrom" in value: @@ -299,7 +299,7 @@ def _add_asset_to_stats(assetmeta: Dict[str, Any], stats: _stats_type) -> None: if value["species"] not in stats["species"]: stats["species"].append(value["species"]) if value.get("identifier", None): - subject = value["identifier"].replace("_", "-") + subject = sanitize_value(value["identifier"]) if subject not in stats["subjects"]: stats["subjects"].append(subject)