Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dandi/dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path

from .consts import dandiset_metadata_file
from .utils import find_parent_directory_containing
from .utils import find_parent_directory_containing, yaml_dump

from . import get_logger

Expand Down Expand Up @@ -52,7 +52,7 @@ def get_dandiset_record(cls, meta):
# It can be edied online and obtained from the dandiarchive.
# It also gets updated using dandi organize
"""
yaml_rec = yaml.dump(meta)
yaml_rec = yaml_dump(meta)
return header + yaml_rec

def update_metadata(self, meta):
Expand Down
2 changes: 1 addition & 1 deletion dandi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def download(
dandiset_path = op.join(output_dir, e["path"])
dandiset_yaml = op.join(dandiset_path, dandiset_metadata_file)
lgr.info(
f"Updating f{dandiset_metadata_file} from obtained dandiset metadata"
f"Updating {dandiset_metadata_file} from obtained dandiset metadata"
)
if op.lexists(dandiset_yaml):
if existing != "overwrite":
Expand Down
14 changes: 14 additions & 0 deletions dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,20 @@ def find_parent_directory_containing(filename, path=None):
path = path.parent # go up


def yaml_dump(rec):
"""Consistent dump into yaml

Of primary importance is default_flow_style=False
to assure proper formatting on versions of pyyaml before
5.1: https://github.com/yaml/pyyaml/pull/256
"""
import yaml
return yaml.safe_dump(
rec,
default_flow_style=False
)


#
# Borrowed from DataLad (MIT license)
#
Expand Down