xlin 0.1.23__tar.gz → 0.1.24__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xlin
3
- Version: 0.1.23
3
+ Version: 0.1.24
4
4
  Summary: toolbox for LinXueyuan
5
5
  License: MIT
6
6
  Author: LinXueyuanStdio
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "xlin"
3
- version = "0.1.23"
3
+ version = "0.1.24"
4
4
  description = "toolbox for LinXueyuan"
5
5
  authors = ["LinXueyuanStdio <23211526+LinXueyuanStdio@users.noreply.github.com>"]
6
6
  license = "MIT"
@@ -224,11 +224,16 @@ def generator_from_paths(paths: List[Path], load_data: Callable[[Path], List[Dic
224
224
 
225
225
 
226
226
 
227
- def append_to_json_list(data: list[dict], file_path: str):
227
+ def append_to_json_list(data: list[dict], file_path: Union[str, Path]):
228
228
  """Append a list of dictionaries to a JSON file."""
229
- with open(file_path, "a") as f:
229
+ file_path = Path(file_path)
230
+ file_path.parent.mkdir(parents=True, exist_ok=True)
231
+ if file_path.exists() and file_path.is_dir():
232
+ print(f"{file_path} is a directory, not a file.")
233
+ return
234
+ with open(file_path, "a", encoding="utf-8") as f:
230
235
  for item in data:
231
- f.write(json.dumps(item) + "\n")
236
+ f.write(json.dumps(item, ensure_ascii=False, separators=(",", ":")) + "\n")
232
237
 
233
238
 
234
239
  def row_to_json(row: dict) -> dict:
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
File without changes
File without changes