Skip to content

Commit cd9b496

Browse files
committed
fixes the yaml writer so that None is written as null
1 parent 690d23b commit cd9b496

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/pynwb/form/spec/write.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def reorder_yaml(self, path):
5252
f_out.write(yaml.dump(sorted_data, Dumper=yaml.RoundTripDumper))
5353

5454
def sort_keys(self, obj):
55+
56+
# Represent None as null
57+
def my_represent_none(self, data):
58+
return self.represent_scalar(u'tag:yaml.org,2002:null', u'null')
59+
yaml.RoundTripRepresenter.add_representer(type(None), my_represent_none)
60+
5561
order = ['neurodata_type_def', 'neurodata_type_inc', 'name', 'dtype', 'doc',
5662
'attributes', 'datasets', 'groups']
5763
if isinstance(obj, dict):

0 commit comments

Comments
 (0)