Skip to content

Commit

Permalink
update our YAML dumper to use tildes for nulls, so our one tilde does…
Browse files Browse the repository at this point in the history
…nt get changed on output from a script
  • Loading branch information
JoshData committed Mar 19, 2013
1 parent be95f01 commit 2292033
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/utils.py
Expand Up @@ -196,6 +196,11 @@ def our_string_representer(dumper, value):
return dumper.represent_scalar(u'tag:yaml.org,2002:str', value, style=style)
Dumper.add_representer(str, our_string_representer)
Dumper.add_representer(unicode, our_string_representer)

# Add a representer for nulls too. YAML accepts "~" for None, but the
# default output converts that to "null".
Dumper.add_representer(type(None), lambda dumper, value : \
dumper.represent_scalar(u'tag:yaml.org,2002:null', u"~"))

# Apply some common settings for loading/dumping YAML and cache the
# data in pickled format which is a LOT faster than YAML.
Expand Down

0 comments on commit 2292033

Please sign in to comment.