Skip to content

Commit

Permalink
Use json5 to load settings files. (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-r-rose authored and blink1073 committed Jun 28, 2019
1 parent a81dea3 commit 3e97c72
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 103 deletions.
99 changes: 0 additions & 99 deletions jupyterlab_server/json_minify.py

This file was deleted.

6 changes: 3 additions & 3 deletions jupyterlab_server/settings_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import os

from glob import glob
import json5
from jsonschema import ValidationError
from jsonschema import Draft4Validator as Validator
from tornado import web

from .json_minify import json_minify
from .server import APIHandler, json_errors


Expand Down Expand Up @@ -66,7 +66,7 @@ def _get_settings(settings_dir, schema_name, schema):
with open(path) as fid:
try: # to load and parse the settings file.
raw = fid.read() or raw
settings = json.loads(json_minify(raw))
settings = json5.loads(raw)
except Exception as e:
raise web.HTTPError(500, parse_error % (schema_name, str(e)))

Expand Down Expand Up @@ -248,7 +248,7 @@ def put(self, schema_name):
schema = _get_schema(schemas_dir, schema_name, overrides)
validator = Validator(schema)
try:
validator.validate(json.loads(json_minify(raw)))
validator.validate(json5.loads(raw))
except ValidationError as e:
raise web.HTTPError(400, validation_error % str(e))

Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
if 'setuptools' in sys.modules:
setup_args['python_requires'] = '>=3.5'
setup_args['extras_require'] = {'test': ['pytest', 'requests']}
setup_args['install_requires'] = ['jsonschema>=3.0.1', 'notebook>=4.2.0']
setup_args['install_requires'] = [
'json5',
'jsonschema>=3.0.1',
'notebook>=4.2.0',
]

if __name__ == '__main__':
setup(**setup_args)

0 comments on commit 3e97c72

Please sign in to comment.