jsonjsdb 0.8.3__tar.gz → 0.8.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/PKG-INFO +1 -1
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/pyproject.toml +13 -4
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/src/jsonjsdb/evolution.py +4 -2
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/src/jsonjsdb/writer.py +8 -3
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/.gitignore +0 -0
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/LICENSE +0 -0
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/README.md +0 -0
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/src/jsonjsdb/__init__.py +0 -0
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/src/jsonjsdb/database.py +0 -0
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/src/jsonjsdb/loader.py +0 -0
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/src/jsonjsdb/py.typed +0 -0
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/src/jsonjsdb/table.py +0 -0
- {jsonjsdb-0.8.3 → jsonjsdb-0.8.4}/src/jsonjsdb/types.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "jsonjsdb"
|
|
7
|
-
version = "0.8.
|
|
7
|
+
version = "0.8.4"
|
|
8
8
|
description = "Python library for JSONJS database loading"
|
|
9
9
|
authors = [{ name = "datannur" }]
|
|
10
10
|
readme = "README.md"
|
|
@@ -31,9 +31,9 @@ Issues = "https://github.com/datannur/jsonjsdb/issues"
|
|
|
31
31
|
|
|
32
32
|
[dependency-groups]
|
|
33
33
|
dev = [
|
|
34
|
-
"pytest",
|
|
35
|
-
"pytest-cov",
|
|
36
|
-
"ruff",
|
|
34
|
+
"pytest>=7.0",
|
|
35
|
+
"pytest-cov>=4.0",
|
|
36
|
+
"ruff>=0.4.0",
|
|
37
37
|
"pyright>=1.1.400",
|
|
38
38
|
]
|
|
39
39
|
|
|
@@ -53,6 +53,15 @@ include = ["src/jsonjsdb"]
|
|
|
53
53
|
pythonVersion = "3.9"
|
|
54
54
|
typeCheckingMode = "standard"
|
|
55
55
|
|
|
56
|
+
[tool.uv]
|
|
57
|
+
constraint-dependencies = [
|
|
58
|
+
"colorama>=0.4",
|
|
59
|
+
"et-xmlfile>=2.0",
|
|
60
|
+
"iniconfig>=2.0",
|
|
61
|
+
"packaging>=21.0",
|
|
62
|
+
"toml>=0.10",
|
|
63
|
+
]
|
|
64
|
+
|
|
56
65
|
[tool.coverage.run]
|
|
57
66
|
source = ["src/jsonjsdb"]
|
|
58
67
|
branch = true
|
|
@@ -411,7 +411,7 @@ def save_evolution(
|
|
|
411
411
|
data = [entry.to_dict() for entry in entries]
|
|
412
412
|
|
|
413
413
|
with open(evolution_json_path, "w", encoding="utf-8") as f:
|
|
414
|
-
json.dump(data, f, indent=2, ensure_ascii=False)
|
|
414
|
+
json.dump(data, f, indent=2, ensure_ascii=False, allow_nan=False)
|
|
415
415
|
f.write("\n")
|
|
416
416
|
|
|
417
417
|
# Write evolution.json.js
|
|
@@ -444,7 +444,9 @@ def save_evolution(
|
|
|
444
444
|
]
|
|
445
445
|
rows.append(row)
|
|
446
446
|
|
|
447
|
-
json_array = json.dumps(
|
|
447
|
+
json_array = json.dumps(
|
|
448
|
+
rows, ensure_ascii=False, separators=(",", ":"), allow_nan=False
|
|
449
|
+
)
|
|
448
450
|
content = f"jsonjs.data['evolution'] = {json_array}\n"
|
|
449
451
|
|
|
450
452
|
with open(evolution_jsonjs_path, "w", encoding="utf-8") as f:
|
|
@@ -13,7 +13,7 @@ def write_table_json(df: pl.DataFrame, path: Path) -> None:
|
|
|
13
13
|
prepared_df = _prepare_df_for_write(df)
|
|
14
14
|
rows = _df_to_json_rows(prepared_df)
|
|
15
15
|
with open(path, "w", encoding="utf-8") as f:
|
|
16
|
-
json.dump(rows, f, indent=2, ensure_ascii=False)
|
|
16
|
+
json.dump(rows, f, indent=2, ensure_ascii=False, allow_nan=False)
|
|
17
17
|
f.write("\n")
|
|
18
18
|
|
|
19
19
|
|
|
@@ -26,7 +26,9 @@ def write_table_jsonjs(df: pl.DataFrame, table_name: str, path: Path) -> None:
|
|
|
26
26
|
for row in prepared_df.iter_rows():
|
|
27
27
|
rows.append(list(row))
|
|
28
28
|
|
|
29
|
-
json_array = json.dumps(
|
|
29
|
+
json_array = json.dumps(
|
|
30
|
+
rows, ensure_ascii=False, separators=(",", ":"), allow_nan=False
|
|
31
|
+
)
|
|
30
32
|
content = f"jsonjs.data['{table_name}'] = {json_array}\n"
|
|
31
33
|
|
|
32
34
|
with open(path, "w", encoding="utf-8") as f:
|
|
@@ -58,7 +60,8 @@ def write_table_index(
|
|
|
58
60
|
|
|
59
61
|
|
|
60
62
|
def _prepare_df_for_write(df: pl.DataFrame) -> pl.DataFrame:
|
|
61
|
-
"""Prepare DataFrame for writing: convert List columns to comma-separated strings
|
|
63
|
+
"""Prepare DataFrame for writing: convert List columns to comma-separated strings
|
|
64
|
+
and NaN to null for valid JSON output."""
|
|
62
65
|
transforms: list[pl.Expr] = []
|
|
63
66
|
|
|
64
67
|
for col_name in df.columns:
|
|
@@ -71,6 +74,8 @@ def _prepare_df_for_write(df: pl.DataFrame) -> pl.DataFrame:
|
|
|
71
74
|
.fill_null("")
|
|
72
75
|
.alias(col_name)
|
|
73
76
|
)
|
|
77
|
+
elif col_type.is_float():
|
|
78
|
+
transforms.append(pl.col(col_name).fill_nan(None))
|
|
74
79
|
else:
|
|
75
80
|
transforms.append(pl.col(col_name))
|
|
76
81
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|