Skip to content

Commit

Permalink
ENH: use sanitize_value helper instead of adhoc replacement of _
Browse files Browse the repository at this point in the history
This seems to Closes #172 as well
  • Loading branch information
yarikoptic committed Aug 13, 2024
1 parent ebb4b46 commit 61c374d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dandischema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .utils import (
TransitionalGenerateJsonSchema,
_ensure_newline,
sanitize_value,
strip_top_level_optional,
version2tuple,
)
Expand Down Expand Up @@ -310,7 +311,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:
Expand Down Expand Up @@ -354,7 +355,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)

Expand Down

0 comments on commit 61c374d

Please sign in to comment.