Skip to content

Commit 81e8149

Browse files
committed
Replace JSON_minify dependency with inline regex comment stripping
JSON_minify seems to be unmaintained and we can do the same with some simple regex.
1 parent 2cb8a97 commit 81e8149

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ authors = [
1616
dependencies = [
1717
"argparse",
1818
"cryptography",
19-
"JSON_minify~=0.3.0",
2019
"pytimeparse~=1.1.8",
2120
"ntplib~=0.4.0",
2221
"haversine~=2.9.0",

src/carconnectivity/carconnectivity_base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import logging
1010
import tempfile
1111
import json
12+
import re
1213
import threading
1314

14-
from json_minify import json_minify
1515

1616
from carconnectivity import carconnectivity, errors, util
1717
from carconnectivity._version import __version__ as __carconnectivity_version__
@@ -25,6 +25,12 @@
2525
LOG: logging.Logger = logging.getLogger("carconnectivity")
2626

2727

28+
def strip_json_comments(text: str) -> str:
29+
text = re.sub(r'/\*.*?\*/', '', text, flags=re.DOTALL)
30+
text = re.sub(r'//.*?$', '', text, flags=re.MULTILINE)
31+
return text
32+
33+
2834
class CLI(): # pylint: disable=too-few-public-methods
2935
"""
3036
Class containing the commandline interface for the carconnectivity package.
@@ -91,7 +97,7 @@ def main(self) -> None: # noqa: C901
9197
try:
9298
with open(file=args.config, mode='r', encoding='utf-8') as config_file:
9399
try:
94-
config_dict = json.loads(json_minify(config_file.read(), strip_space=False))
100+
config_dict = json.loads(strip_json_comments(config_file.read()))
95101
car_connectivity = carconnectivity.CarConnectivity(config=config_dict, tokenstore_file=args.tokenfile, cache_file=args.cachefile)
96102
car_connectivity.startup()
97103

0 commit comments

Comments
 (0)