Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Feb 7, 2025
1 parent 9ec7823 commit d2e3525
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env sh

shopt -s globstar
rm -rf generated_settings
rm -rf generated_settings .tox
rm -rf .cache
rm -rf data.nt tests/data.nt
rm -rf /tmp/pytest-of-$USER
Expand Down
6 changes: 2 additions & 4 deletions doc/alternatives.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ code more robust with little to no increase in complexity:
The type of the value ``2`` is ambiguous; it may be integer or real. This
may cause problems when combined into an array, such as ``[1.85, 1.94, 2,
2.09]``. A casually written program may choke on a non-homogeneous array
that consists of an integer among the floats. This is the reason that JSON
does not distinguish between integers and reals.
that consists of an integer among the floats.

YAML is notorious for ambiguities because it allows unquoted strings. ``2``
is a valid integer, real, and string. Similarly, ``no`` is a valid Boolean
Expand Down Expand Up @@ -390,8 +389,7 @@ code more robust with little to no increase in complexity:

.. collapse::
Support for non-string types creates the requirement for quoting and
escaping, and ultimately leads to either verbosity (JSON) or ambiguity
(YAML).
escaping, and ultimately leads to either clutter (JSON) or ambiguity (YAML).

Every additional supported data type brings a challenge; how to
unambiguously distinguish it from the others. The challenge is particularly
Expand Down
4 changes: 2 additions & 2 deletions examples/conversion-utilities/nestedtext-to-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ try:
if input_filename:
input_path = Path(input_filename)
data = nt.load(input_path, top='any', on_dup=on_dup)
yaml_content = yaml.dump(data)
yaml_content = yaml.dump(data, allow_unicode=True)
output_path = input_path.with_suffix('.yaml')
if output_path.exists():
if not cmdline['--force']:
fatal('file exists, use -f to force over-write.', culprit=output_path)
output_path.write_text(yaml_content, encoding='utf-8')
else:
data = nt.load(sys.stdin, top='any', on_dup=on_dup)
yaml_content = yaml.dump(data)
yaml_content = yaml.dump(data, allow_unicode=True)
sys.stdout.write(yaml_content + '\n')
except OSError as e:
fatal(os_error(e))
Expand Down

0 comments on commit d2e3525

Please sign in to comment.