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 Apr 6, 2023
1 parent ad0cb15 commit e8aba8e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dandischema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e8aba8e

Please sign in to comment.