././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1601923740.9477937 commentjson-0.9.0/0000755000076600000240000000000000000000000015664 5ustar00vaidikkapoorstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/LICENSE.rst0000644000076600000240000000207000000000000017477 0ustar00vaidikkapoorstaff00000000000000The MIT License (MIT) Copyright (c) 2014 Vaidik Kapoor Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1596905748.0 commentjson-0.9.0/MANIFEST.in0000644000076600000240000000001600000000000017417 0ustar00vaidikkapoorstaff00000000000000include *.rst ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1601923740.947504 commentjson-0.9.0/PKG-INFO0000644000076600000240000000425300000000000016765 0ustar00vaidikkapoorstaff00000000000000Metadata-Version: 1.1 Name: commentjson Version: 0.9.0 Summary: Add Python and JavaScript style comments in your JSON files. Home-page: https://github.com/vaidik/commentjson Author: Vaidik Kapoor Author-email: kapoor.vaidik@gmail.com License: UNKNOWN Description: =========== commentjson =========== `commentjson` (Comment JSON) is a Python package that helps you create JSON files with Python and JavaScript style inline comments. Its API is very similar to the Python standard library's `json`_ module. .. _`json`: http://docs.python.org/2/library/json.html .. image:: https://travis-ci.org/vaidik/commentjson.png Installation ============ pip install commentjson Basic Usage =========== .. code-block:: python >>> import commentjson >>> >>> json_string = """{ ... "name": "Vaidik Kapoor", # Person's name ... "location": "Delhi, India", // Person's location ... ... # Section contains info about ... // person's appearance ... "appearance": { ... "hair_color": "black", ... "eyes_color": "black", ... "height": "6" ... } ... }""" >>> >>> json_loaded = commentjson.loads(json_string) >>> print json_loaded {u'appearance': {u'eyes_color': u'black', u'hair_color': u'black', u'height': u'6'}, u'name': u'Vaidik Kapoor', u'location': u'Delhi, India'} Documentation ============= Complete documentation can be found `here`_. .. _`here`: http://commentjson.readthedocs.org/en/latest/ Tests ===== python setup.py test License ======= See `license`_. .. _`license`: https://github.com/vaidik/commentjson/blob/master/LICENSE.rst Platform: UNKNOWN Classifier: Programming Language :: Python ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/README.rst0000755000076600000240000000257300000000000017365 0ustar00vaidikkapoorstaff00000000000000=========== commentjson =========== `commentjson` (Comment JSON) is a Python package that helps you create JSON files with Python and JavaScript style inline comments. Its API is very similar to the Python standard library's `json`_ module. .. _`json`: http://docs.python.org/2/library/json.html .. image:: https://travis-ci.org/vaidik/commentjson.png Installation ============ pip install commentjson Basic Usage =========== .. code-block:: python >>> import commentjson >>> >>> json_string = """{ ... "name": "Vaidik Kapoor", # Person's name ... "location": "Delhi, India", // Person's location ... ... # Section contains info about ... // person's appearance ... "appearance": { ... "hair_color": "black", ... "eyes_color": "black", ... "height": "6" ... } ... }""" >>> >>> json_loaded = commentjson.loads(json_string) >>> print json_loaded {u'appearance': {u'eyes_color': u'black', u'hair_color': u'black', u'height': u'6'}, u'name': u'Vaidik Kapoor', u'location': u'Delhi, India'} Documentation ============= Complete documentation can be found `here`_. .. _`here`: http://commentjson.readthedocs.org/en/latest/ Tests ===== python setup.py test License ======= See `license`_. .. _`license`: https://github.com/vaidik/commentjson/blob/master/LICENSE.rst ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1601923740.8720849 commentjson-0.9.0/commentjson/0000755000076600000240000000000000000000000020220 5ustar00vaidikkapoorstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/__init__.py0000644000076600000240000000032100000000000022325 0ustar00vaidikkapoorstaff00000000000000from .commentjson import dump from .commentjson import dumps from .commentjson import JSONLibraryException from .commentjson import ParserException from .commentjson import load from .commentjson import loads ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1601892449.0 commentjson-0.9.0/commentjson/commentjson.py0000755000076600000240000001577000000000000023143 0ustar00vaidikkapoorstaff00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """Add JavaScript or Python style comments in JSON. commentjson (Comment JSON) is a Python package that helps you create JSON files with Python and JavaScript style inline comments. Its API is very similar to the Python standard library’s json module. """ from __future__ import print_function from __future__ import division from __future__ import absolute_import from __future__ import unicode_literals import codecs import traceback try: import json except ImportError: # If python version is 2.5 or less, use simplejson import simplejson as json import lark from lark import Lark from lark.lexer import Token from lark.reconstruct import Reconstructor from lark.tree import Tree parser = Lark(''' ?start: value ?value: object | array | string | SIGNED_NUMBER -> number | "true" -> true | "false" -> false | "null" -> null array : "[" [value ("," value)*] TRAILING_COMMA? "]" object : "{" [pair ("," pair)*] TRAILING_COMMA? "}" pair : string ":" value string : ESCAPED_STRING COMMENT: /(#|\\/\\/)[^\\n]*/ TRAILING_COMMA: "," %import common.ESCAPED_STRING %import common.SIGNED_NUMBER %import common.WS %ignore WS %ignore COMMENT ''', maybe_placeholders=False, parser='lalr') serializer = Reconstructor(parser) def detect_encoding(b): ''' Taken from `json` package in CPython 3.7. Source can be found at https://bit.ly/2OHqCIK. ''' bstartswith = b.startswith if bstartswith((codecs.BOM_UTF32_BE, codecs.BOM_UTF32_LE)): return 'utf-32' if bstartswith((codecs.BOM_UTF16_BE, codecs.BOM_UTF16_LE)): return 'utf-16' if bstartswith(codecs.BOM_UTF8): return 'utf-8-sig' if len(b) >= 4: if not b[0]: # 00 00 -- -- - utf-32-be # 00 XX -- -- - utf-16-be return 'utf-16-be' if b[1] else 'utf-32-be' if not b[1]: # XX 00 00 00 - utf-32-le # XX 00 00 XX - utf-16-le # XX 00 XX -- - utf-16-le return 'utf-16-le' if b[2] or b[3] else 'utf-32-le' elif len(b) == 2: if not b[0]: # 00 XX - utf-16-be return 'utf-16-be' if not b[1]: # XX 00 - utf-16-le return 'utf-16-le' # default return 'utf-8' class BaseException(Exception): ''' Base exception to be implemented and raised while handling exceptions raised by libraries used in `commentjson`. Sets message of self in a way that it clearly calls out that the exception was raised by another library, along with the entire stacktrace of the exception raised by the other library. ''' def __init__(self, exc): if self.library is None: raise NotImplementedError( 'Value of library must be set in the ' 'inherited exception class.') tb = traceback.format_exc() tb = '\n'.join(' ' * 4 + line_ for line_ in tb.split('\n')) error = None try: error = exc.msg except AttributeError: try: error = exc.message except AttributeError: error = str(exc) self.message = '\n'.join([ 'JSON Library Exception\n', ('Exception thrown by library (%s): ' '\033[4;37m%s\033[0m\n' % (self.library, error)), '%s' % tb, ]) Exception.__init__(self, self.message) class ParserException(BaseException): '''Exception raised when the `lark` raises an exception i.e. the exception is not caused by `commentjson` and caused by the use of `lark` in `commentjson`. ''' library = 'lark' class JSONLibraryException(BaseException): '''Exception raised when the `json` raises an exception i.e. the exception is not caused by `commentjson` and caused by the use of `json` in `commentjson`. .. note:: As of now, ``commentjson`` supports only standard library's ``json`` module. It might start supporting other widely-used contributed JSON libraries in the future. ''' library = 'json' def _remove_trailing_commas(tree): if isinstance(tree, Tree): tree.children = [ _remove_trailing_commas(ch) for ch in tree.children if not (isinstance(ch, Token) and ch.type == 'TRAILING_COMMA') ] return tree def loads(text, *args, **kwargs): ''' Deserialize `text` (a `str` or `unicode` instance containing a JSON document with Python or JavaScript like comments) to a Python object. :param text: serialized JSON string with or without comments. :param kwargs: all the arguments that `json.loads `_ accepts. :returns: dict or list. ''' if isinstance(text, (bytes, bytearray)): text = text.decode(detect_encoding(text), 'surrogatepass') try: parsed = _remove_trailing_commas(parser.parse(text)) final_text = serializer.reconstruct(parsed) except lark.exceptions.UnexpectedCharacters: raise ValueError('Unable to parse text', text) return json.loads(final_text, *args, **kwargs) def dumps(obj, **kwargs): ''' Serialize `obj` to a JSON formatted `str`. Accepts the same arguments as `json` module in stdlib. :param obj: a JSON serializable Python object. :param kwargs: all the arguments that `json.dumps `_ accepts. :raises: commentjson.JSONLibraryException :returns str: serialized string. ''' return json.dumps(obj, **kwargs) def load(fp, **kwargs): ''' Deserialize `fp` (a `.read()`-supporting file-like object containing a JSON document with Python or JavaScript like comments) to a Python object. :param fp: a `.read()`-supporting file-like object containing a JSON document with or without comments. :param kwargs: all the arguments that `json.load `_ accepts. :raises: commentjson.JSONLibraryException :returns: dict or list. ''' try: return loads(fp.read(), **kwargs) except Exception as e: raise JSONLibraryException(e) def dump(obj, fp, **kwargs): ''' Serialize `obj` as a JSON formatted stream to `fp` (a `.write()`-supporting file-like object). Accepts the same arguments as `json` module in stdlib. :param obj: a JSON serializable Python object. :param fp: a `.read()`-supporting file-like object containing a JSON document with or without comments. :param kwargs: all the arguments that `json.dump `_ accepts. :raises: commentjson.JSONLibraryException ''' try: json.dump(obj, fp, **kwargs) except Exception as e: raise JSONLibraryException(e) ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1601923740.875815 commentjson-0.9.0/commentjson/tests/0000755000076600000240000000000000000000000021362 5ustar00vaidikkapoorstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/__init__.py0000755000076600000240000000000000000000000023464 0ustar00vaidikkapoorstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1601892449.0 commentjson-0.9.0/commentjson/tests/test_commentjson.py0000755000076600000240000001210100000000000025325 0ustar00vaidikkapoorstaff00000000000000try: import json except ImportError: import simplejson as json import commentjson import os import unittest from six import iteritems class TestCommentJson(unittest.TestCase): def setUp(self): self.test_json = {} self.path = os.path.dirname(os.path.abspath(__file__)) self.files = ('sample', 'line_comment', 'inline_last_float', 'inline_last_int', 'nested_object', 'string_with_hash', 'string_with_inline_comment', 'inline_has_special_characters', 'array_with_hash', 'inline_last_quote', 'trailing_comma') for file_ in self.files: fpath = os.path.join(self.path, file_) with open('%s-uncommented.json' % fpath) as fp: uncommented = fp.read() with open('%s-commented.json' % fpath) as fp: commented = fp.read() self.test_json.update({ file_: { 'uncommented': uncommented, 'commented': commented, }, }) def tearDown(self): test_file_path = os.path.join(self.path, 'test.json') if os.path.exists(test_file_path): os.unlink(test_file_path) def test_dumping_parsing_simple_string(self): string = '//' self.assertEqual(commentjson.loads(commentjson.dumps(string)), string) string = '#' self.assertEqual(commentjson.loads(commentjson.dumps(string)), string) def test_dumps(self): test_dict = dict(a=1, b=2) c_dump = commentjson.dumps(test_dict) j_dump = json.dumps(test_dict) assert c_dump, j_dump def test_dumps_with_kwargs(self): test_dict = dict(a=1, b=2) test_kwargs = dict(indent=4) c_dump = commentjson.dumps(test_dict, **test_kwargs) j_dump = json.dumps(test_dict, **test_kwargs) assert c_dump, j_dump def test_dumps_throws_exception(self): class Unserializable: pass self.assertRaises(TypeError, commentjson.dumps, Unserializable) def test_loads(self): for index, test_json_ in iteritems(self.test_json): commented = test_json_['commented'] uncommented = test_json_['uncommented'] self.assertEqual( commentjson.loads(commented), json.loads(uncommented), 'Failed for test: %s' % test_json_['commented']) def test_loads_with_kwargs(self): def test_hook(loaded_dict): return {} commented = self.test_json['sample']['commented'] test_kwargs = dict(object_hook=test_hook) c_load = commentjson.loads(commented, **test_kwargs) # make sure that object_hook did its work assert c_load == {} def test_loads_throws_exception(self): self.assertRaises(ValueError, commentjson.loads, 'Unserializable text') def test_dump(self): test_dict = dict(a=1, b=2) wfp = open(os.path.join(self.path, 'test.json'), 'w') commentjson.dump(test_dict, wfp) wfp.close() rfp = open(os.path.join(self.path, 'test.json'), 'r') j_dump = json.dumps(test_dict) assert rfp.read(), j_dump rfp.close() def test_dump_with_kwargs(self): test_dict = dict(a=1, b=2) test_kwargs = dict(indent=4) wfp = open(os.path.join(self.path, 'test.json'), 'w') commentjson.dump(test_dict, wfp, **test_kwargs) wfp.close() rfp = open(os.path.join(self.path, 'test.json'), 'r') j_dump = json.dumps(test_dict, **test_kwargs) c_dump = rfp.read() assert c_dump == j_dump, c_dump rfp.close() def test_dump_throws_exception(self): class Unserializable: pass fp = open(os.path.join(self.path, 'test.json'), 'w') self.assertRaises(commentjson.JSONLibraryException, commentjson.dump, Unserializable, fp) fp.close() def test_load(self): for file_ in self.files: rfp = open(os.path.join(self.path, '%s-commented.json' % file_), 'r') uncommented = self.test_json[file_]['uncommented'] assert commentjson.load(rfp) == json.loads(uncommented) rfp.close() def test_load_with_kwargs(self): def test_hook(loaded_dict): return {} test_kwargs = dict(object_hook=test_hook) rfp = open(os.path.join(self.path, 'sample-commented.json'), 'r') self.assertEqual(commentjson.load(rfp, **test_kwargs), {}) rfp.close() def test_load_throws_exception(self): wfp = open(os.path.join(self.path, 'test.json'), 'w') wfp.write('Unserializable text.') wfp.close() rfp = open(os.path.join(self.path, 'test.json'), 'r') self.assertRaises(commentjson.JSONLibraryException, commentjson.load, rfp) rfp.close() if __name__ == '__main__': unittest.main() ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1601923740.9468558 commentjson-0.9.0/commentjson/tests/test_json/0000755000076600000240000000000000000000000023372 5ustar00vaidikkapoorstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/__init__.py0000644000076600000240000000027700000000000025511 0ustar00vaidikkapoorstaff00000000000000import unittest import commentjson class CommentJsonTest(unittest.TestCase): json = commentjson loads = staticmethod(commentjson.loads) dumps = staticmethod(commentjson.dumps) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_decode.py0000644000076600000240000000454200000000000026233 0ustar00vaidikkapoorstaff00000000000000import six import platform import unittest from . import CommentJsonTest if six.PY2: from json.tests.test_decode import TestDecode else: from test.test_json.test_decode import TestDecode version = platform.sys.version_info class TestCommentJsonDecode(TestDecode, CommentJsonTest): def __init__(self, *args, **kwargs): super(TestCommentJsonDecode, self).__init__(*args, **kwargs) self.JSONDecodeError = ValueError _json = self.json class Decoder(object): def __init__(self): self.decode = _json.loads self.json.decoder = Decoder() setattr(self.json.decoder, 'JSONDecoder', lambda: Decoder()) @unittest.skipIf((version.major == 2 or (version.major == 3 and version.minor <= 5)), ('Invalid test case since the the exception raised by' 'commentjson is different from the one raised by json ' 'package.')) def test_extra_data(self): pass @unittest.skipIf((version.major == 2 or (version.major == 3 and version.minor <= 5)), ('Skipping since the test case depends on APIs of JSON ' ' package that are not supported by commentjson')) def test_keys_reuse(self): pass @unittest.skipIf(version.major == 2, ('Test case not present in test suite ' 'for Python 2')) def test_invalid_input_type(self): try: super(TestCommentJsonDecode, self).test_invalid_input_type() except AssertionError as e: if 'does not match' not in e.args[0]: raise e @unittest.skipIf(version.major == 2, ('Test case not present in test suite ' 'for Python 2')) def test_string_with_utf8_bom(self): try: super(TestCommentJsonDecode, self).test_string_with_utf8_bom() except AssertionError as e: if 'not found' not in e.args[0]: raise e @unittest.skipIf((version.major == 2 or (version.major == 3 and version.minor <= 5)), ('Invalid test case since the API used in the actual ' 'test case is not supported by commentjson.')) def test_negative_index(self): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_dump.py0000644000076600000240000000042400000000000025750 0ustar00vaidikkapoorstaff00000000000000import six import platform from . import CommentJsonTest if six.PY2: from json.tests.test_dump import TestDump else: from test.test_json.test_dump import TestDump version = platform.sys.version_info class TestCommentJsonDump(TestDump, CommentJsonTest): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_encode_basestring_ascii.py0000644000076600000240000000107300000000000031632 0ustar00vaidikkapoorstaff00000000000000import six import platform import unittest from . import CommentJsonTest if six.PY2: from json.tests.test_encode_basestring_ascii import TestEncodeBasestringAscii else: from test.test_json.test_encode_basestring_ascii import TestEncodeBasestringAscii version = platform.sys.version_info class TestCommentJsonEncodeBasestringAscii(TestEncodeBasestringAscii, CommentJsonTest): @unittest.skip('Skip this test since commentjson does not support the API ' 'used in the test case.') def test_encode_basestring_ascii(self): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_float.py0000644000076600000240000000061300000000000026110 0ustar00vaidikkapoorstaff00000000000000import six import platform import unittest from . import CommentJsonTest if six.PY2: from json.tests.test_float import TestFloat else: from test.test_json.test_float import TestFloat version = platform.sys.version_info class TestCommentJsonFloat(TestFloat, CommentJsonTest): @unittest.skip('Infinity as a value is not supported yet') def test_allow_nan(self): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_indent.py0000644000076600000240000000044000000000000026262 0ustar00vaidikkapoorstaff00000000000000import six import platform from . import CommentJsonTest if six.PY2: from json.tests.test_indent import TestIndent else: from test.test_json.test_indent import TestIndent version = platform.sys.version_info class TestCommentJsonIndent(TestIndent, CommentJsonTest): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_pass1.py0000644000076600000240000000043200000000000026031 0ustar00vaidikkapoorstaff00000000000000import six import platform from . import CommentJsonTest if six.PY2: from json.tests.test_pass1 import TestPass1 else: from test.test_json.test_pass1 import TestPass1 version = platform.sys.version_info class TestCommentJsonPass1(TestPass1, CommentJsonTest): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_pass2.py0000644000076600000240000000043200000000000026032 0ustar00vaidikkapoorstaff00000000000000import six import platform from . import CommentJsonTest if six.PY2: from json.tests.test_pass2 import TestPass2 else: from test.test_json.test_pass2 import TestPass2 version = platform.sys.version_info class TestCommentJsonPass2(TestPass2, CommentJsonTest): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_pass3.py0000644000076600000240000000043200000000000026033 0ustar00vaidikkapoorstaff00000000000000import six import platform from . import CommentJsonTest if six.PY2: from json.tests.test_pass3 import TestPass3 else: from test.test_json.test_pass3 import TestPass3 version = platform.sys.version_info class TestCommentJsonPass3(TestPass3, CommentJsonTest): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_recursion.py0000644000076600000240000000142300000000000027014 0ustar00vaidikkapoorstaff00000000000000import six import platform import unittest from . import CommentJsonTest if six.PY2: from json.tests.test_recursion import TestRecursion else: from test.test_json.test_recursion import TestRecursion version = platform.sys.version_info class TestCommentJsonRecursion(TestRecursion, CommentJsonTest): @unittest.skipIf(version.major == 3, ('Invalid test case since the API used in the actual ' 'test case is not supported by commentjson.')) def test_defaultrecursion(self): pass @unittest.skipIf(version.major == 3, ('Invalid test case since the API used in the actual ' 'test case is not supported by commentjson.')) def test_endless_recursion(self): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_separators.py0000644000076600000240000000047000000000000027167 0ustar00vaidikkapoorstaff00000000000000import six import platform from . import CommentJsonTest if six.PY2: from json.tests.test_separators import TestSeparators else: from test.test_json.test_separators import TestSeparators version = platform.sys.version_info class TestCommentJsonSeparators(TestSeparators, CommentJsonTest): pass ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1589697230.0 commentjson-0.9.0/commentjson/tests/test_json/test_unicode.py0000644000076600000240000000150700000000000026434 0ustar00vaidikkapoorstaff00000000000000import six import platform import unittest from . import CommentJsonTest if six.PY2: from json.tests.test_unicode import TestUnicode else: from test.test_json.test_unicode import TestUnicode version = platform.sys.version_info class TestCommentJsonUnicode(TestUnicode, CommentJsonTest): @unittest.skipIf(version.major == 3 and version.minor <= 5, ('Invalid test case since the API used in the actual ' 'test case is not supported by commentjson.')) def test_encoding1(self): pass @unittest.skipIf((version.major == 2 or (version.major == 3 and version.minor <= 5)), 'Invalid test case for Python 2.7 and 3+ to 3.5.') def test_bytes_decode(self): TestCommentJsonUnicode.__bases__[0].test_bytes_decode(self) ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1601923740.8750892 commentjson-0.9.0/commentjson.egg-info/0000755000076600000240000000000000000000000021712 5ustar00vaidikkapoorstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1601923740.0 commentjson-0.9.0/commentjson.egg-info/PKG-INFO0000644000076600000240000000425300000000000023013 0ustar00vaidikkapoorstaff00000000000000Metadata-Version: 1.1 Name: commentjson Version: 0.9.0 Summary: Add Python and JavaScript style comments in your JSON files. Home-page: https://github.com/vaidik/commentjson Author: Vaidik Kapoor Author-email: kapoor.vaidik@gmail.com License: UNKNOWN Description: =========== commentjson =========== `commentjson` (Comment JSON) is a Python package that helps you create JSON files with Python and JavaScript style inline comments. Its API is very similar to the Python standard library's `json`_ module. .. _`json`: http://docs.python.org/2/library/json.html .. image:: https://travis-ci.org/vaidik/commentjson.png Installation ============ pip install commentjson Basic Usage =========== .. code-block:: python >>> import commentjson >>> >>> json_string = """{ ... "name": "Vaidik Kapoor", # Person's name ... "location": "Delhi, India", // Person's location ... ... # Section contains info about ... // person's appearance ... "appearance": { ... "hair_color": "black", ... "eyes_color": "black", ... "height": "6" ... } ... }""" >>> >>> json_loaded = commentjson.loads(json_string) >>> print json_loaded {u'appearance': {u'eyes_color': u'black', u'hair_color': u'black', u'height': u'6'}, u'name': u'Vaidik Kapoor', u'location': u'Delhi, India'} Documentation ============= Complete documentation can be found `here`_. .. _`here`: http://commentjson.readthedocs.org/en/latest/ Tests ===== python setup.py test License ======= See `license`_. .. _`license`: https://github.com/vaidik/commentjson/blob/master/LICENSE.rst Platform: UNKNOWN Classifier: Programming Language :: Python ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1601923740.0 commentjson-0.9.0/commentjson.egg-info/SOURCES.txt0000644000076600000240000000160600000000000023601 0ustar00vaidikkapoorstaff00000000000000LICENSE.rst MANIFEST.in README.rst setup.py commentjson/__init__.py commentjson/commentjson.py commentjson.egg-info/PKG-INFO commentjson.egg-info/SOURCES.txt commentjson.egg-info/dependency_links.txt commentjson.egg-info/not-zip-safe commentjson.egg-info/requires.txt commentjson.egg-info/top_level.txt commentjson/tests/__init__.py commentjson/tests/test_commentjson.py commentjson/tests/test_json/__init__.py commentjson/tests/test_json/test_decode.py commentjson/tests/test_json/test_dump.py commentjson/tests/test_json/test_encode_basestring_ascii.py commentjson/tests/test_json/test_float.py commentjson/tests/test_json/test_indent.py commentjson/tests/test_json/test_pass1.py commentjson/tests/test_json/test_pass2.py commentjson/tests/test_json/test_pass3.py commentjson/tests/test_json/test_recursion.py commentjson/tests/test_json/test_separators.py commentjson/tests/test_json/test_unicode.py././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1601923740.0 commentjson-0.9.0/commentjson.egg-info/dependency_links.txt0000644000076600000240000000000100000000000025760 0ustar00vaidikkapoorstaff00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1590893403.0 commentjson-0.9.0/commentjson.egg-info/not-zip-safe0000644000076600000240000000000100000000000024140 0ustar00vaidikkapoorstaff00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1601923740.0 commentjson-0.9.0/commentjson.egg-info/requires.txt0000644000076600000240000000003200000000000024305 0ustar00vaidikkapoorstaff00000000000000lark-parser<0.8.0,>=0.7.1 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1601923740.0 commentjson-0.9.0/commentjson.egg-info/top_level.txt0000644000076600000240000000001400000000000024437 0ustar00vaidikkapoorstaff00000000000000commentjson ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1601923740.9478767 commentjson-0.9.0/setup.cfg0000644000076600000240000000004600000000000017505 0ustar00vaidikkapoorstaff00000000000000[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1601921922.0 commentjson-0.9.0/setup.py0000644000076600000240000000206300000000000017377 0ustar00vaidikkapoorstaff00000000000000from __future__ import with_statement import os import sys from setuptools import setup, find_packages __version__ = '0.9.0' install_requires = [ 'lark-parser>=0.7.1,<0.8.0' ] if sys.version_info <= (2, 6): install_requires.append('simplejson') description = '' path = lambda fname: os.path.join(os.path.dirname(__file__), fname) for file_ in ('README',): with open(path('%s.rst' % file_)) as f: description += f.read() + '\n\n' classifiers = ["Programming Language :: Python"] setup(name='commentjson', version=__version__, url='https://github.com/vaidik/commentjson', packages=find_packages(), long_description=description, description=("Add Python and JavaScript style comments in your JSON " "files."), author="Vaidik Kapoor", author_email="kapoor.vaidik@gmail.com", include_package_data=True, zip_safe=False, classifiers=classifiers, install_requires=install_requires, tests_require=[ 'six', ], test_suite='commentjson.tests')