summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/json
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Lib/json
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Lib/json')
-rw-r--r--contrib/tools/python3/src/Lib/json/__init__.py6
-rw-r--r--contrib/tools/python3/src/Lib/json/encoder.py8
-rw-r--r--contrib/tools/python3/src/Lib/json/tool.py106
3 files changed, 60 insertions, 60 deletions
diff --git a/contrib/tools/python3/src/Lib/json/__init__.py b/contrib/tools/python3/src/Lib/json/__init__.py
index e4c21daaf3e..f7e69c9da4c 100644
--- a/contrib/tools/python3/src/Lib/json/__init__.py
+++ b/contrib/tools/python3/src/Lib/json/__init__.py
@@ -133,7 +133,7 @@ def dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True,
If ``check_circular`` is false, then the circular reference check
for container types will be skipped and a circular reference will
- result in an ``RecursionError`` (or worse).
+ result in an ``RecursionError`` (or worse).
If ``allow_nan`` is false, then it will be a ``ValueError`` to
serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``)
@@ -195,7 +195,7 @@ def dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,
If ``check_circular`` is false, then the circular reference check
for container types will be skipped and a circular reference will
- result in an ``RecursionError`` (or worse).
+ result in an ``RecursionError`` (or worse).
If ``allow_nan`` is false, then it will be a ``ValueError`` to
serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
@@ -296,7 +296,7 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
-def loads(s, *, cls=None, object_hook=None, parse_float=None,
+def loads(s, *, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None, **kw):
"""Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
containing a JSON document) to a Python object.
diff --git a/contrib/tools/python3/src/Lib/json/encoder.py b/contrib/tools/python3/src/Lib/json/encoder.py
index 21bff2c1a1f..e6b844f1614 100644
--- a/contrib/tools/python3/src/Lib/json/encoder.py
+++ b/contrib/tools/python3/src/Lib/json/encoder.py
@@ -116,7 +116,7 @@ class JSONEncoder(object):
If check_circular is true, then lists, dicts, and custom encoded
objects will be checked for circular references during encoding to
- prevent an infinite recursion (which would cause an RecursionError).
+ prevent an infinite recursion (which would cause an RecursionError).
Otherwise, no such check takes place.
If allow_nan is true, then NaN, Infinity, and -Infinity will be
@@ -268,7 +268,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
list=list,
str=str,
tuple=tuple,
- _intstr=int.__repr__,
+ _intstr=int.__repr__,
):
if _indent is not None and not isinstance(_indent, str):
@@ -307,7 +307,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
elif value is False:
yield buf + 'false'
elif isinstance(value, int):
- # Subclasses of int/float may override __repr__, but we still
+ # Subclasses of int/float may override __repr__, but we still
# want to encode them as integers/floats in JSON. One example
# within the standard library is IntEnum.
yield buf + _intstr(value)
@@ -350,7 +350,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
item_separator = _item_separator
first = True
if _sort_keys:
- items = sorted(dct.items())
+ items = sorted(dct.items())
else:
items = dct.items()
for key, value in items:
diff --git a/contrib/tools/python3/src/Lib/json/tool.py b/contrib/tools/python3/src/Lib/json/tool.py
index 0490b8c0be1..d204f960f59 100644
--- a/contrib/tools/python3/src/Lib/json/tool.py
+++ b/contrib/tools/python3/src/Lib/json/tool.py
@@ -13,7 +13,7 @@ Usage::
import argparse
import json
import sys
-from pathlib import Path
+from pathlib import Path
def main():
@@ -21,65 +21,65 @@ def main():
description = ('A simple command line interface for json module '
'to validate and pretty-print JSON objects.')
parser = argparse.ArgumentParser(prog=prog, description=description)
- parser.add_argument('infile', nargs='?',
- type=argparse.FileType(encoding="utf-8"),
- help='a JSON file to be validated or pretty-printed',
- default=sys.stdin)
- parser.add_argument('outfile', nargs='?',
- type=Path,
- help='write the output of infile to outfile',
- default=None)
+ parser.add_argument('infile', nargs='?',
+ type=argparse.FileType(encoding="utf-8"),
+ help='a JSON file to be validated or pretty-printed',
+ default=sys.stdin)
+ parser.add_argument('outfile', nargs='?',
+ type=Path,
+ help='write the output of infile to outfile',
+ default=None)
parser.add_argument('--sort-keys', action='store_true', default=False,
help='sort the output of dictionaries alphabetically by key')
- parser.add_argument('--no-ensure-ascii', dest='ensure_ascii', action='store_false',
- help='disable escaping of non-ASCII characters')
- parser.add_argument('--json-lines', action='store_true', default=False,
- help='parse input using the JSON Lines format. '
- 'Use with --no-indent or --compact to produce valid JSON Lines output.')
- group = parser.add_mutually_exclusive_group()
- group.add_argument('--indent', default=4, type=int,
- help='separate items with newlines and use this number '
- 'of spaces for indentation')
- group.add_argument('--tab', action='store_const', dest='indent',
- const='\t', help='separate items with newlines and use '
- 'tabs for indentation')
- group.add_argument('--no-indent', action='store_const', dest='indent',
- const=None,
- help='separate items with spaces rather than newlines')
- group.add_argument('--compact', action='store_true',
- help='suppress all whitespace separation (most compact)')
+ parser.add_argument('--no-ensure-ascii', dest='ensure_ascii', action='store_false',
+ help='disable escaping of non-ASCII characters')
+ parser.add_argument('--json-lines', action='store_true', default=False,
+ help='parse input using the JSON Lines format. '
+ 'Use with --no-indent or --compact to produce valid JSON Lines output.')
+ group = parser.add_mutually_exclusive_group()
+ group.add_argument('--indent', default=4, type=int,
+ help='separate items with newlines and use this number '
+ 'of spaces for indentation')
+ group.add_argument('--tab', action='store_const', dest='indent',
+ const='\t', help='separate items with newlines and use '
+ 'tabs for indentation')
+ group.add_argument('--no-indent', action='store_const', dest='indent',
+ const=None,
+ help='separate items with spaces rather than newlines')
+ group.add_argument('--compact', action='store_true',
+ help='suppress all whitespace separation (most compact)')
options = parser.parse_args()
- dump_args = {
- 'sort_keys': options.sort_keys,
- 'indent': options.indent,
- 'ensure_ascii': options.ensure_ascii,
- }
- if options.compact:
- dump_args['indent'] = None
- dump_args['separators'] = ',', ':'
-
- with options.infile as infile:
+ dump_args = {
+ 'sort_keys': options.sort_keys,
+ 'indent': options.indent,
+ 'ensure_ascii': options.ensure_ascii,
+ }
+ if options.compact:
+ dump_args['indent'] = None
+ dump_args['separators'] = ',', ':'
+
+ with options.infile as infile:
try:
- if options.json_lines:
- objs = (json.loads(line) for line in infile)
- else:
- objs = (json.load(infile),)
-
- if options.outfile is None:
- out = sys.stdout
- else:
- out = options.outfile.open('w', encoding='utf-8')
- with out as outfile:
- for obj in objs:
- json.dump(obj, outfile, **dump_args)
- outfile.write('\n')
+ if options.json_lines:
+ objs = (json.loads(line) for line in infile)
+ else:
+ objs = (json.load(infile),)
+
+ if options.outfile is None:
+ out = sys.stdout
+ else:
+ out = options.outfile.open('w', encoding='utf-8')
+ with out as outfile:
+ for obj in objs:
+ json.dump(obj, outfile, **dump_args)
+ outfile.write('\n')
except ValueError as e:
raise SystemExit(e)
if __name__ == '__main__':
- try:
- main()
- except BrokenPipeError as exc:
- sys.exit(exc.errno)
+ try:
+ main()
+ except BrokenPipeError as exc:
+ sys.exit(exc.errno)