mirror of
https://github.com/revanced/revanced-static-api.git
synced 2025-04-29 22:24:37 +02:00
feat: Indent generated JSON files
This allows easier version control using Git.
This commit is contained in:
parent
0ccdab1569
commit
47fcdd1ce3
@ -1,7 +1,7 @@
|
||||
import json
|
||||
from os.path import join
|
||||
from app import api
|
||||
from app.utils import get_repository_name, write_json, read_json, create_if_not_exists
|
||||
from app.utils import get_repository_name, to_json, write_json, read_json, create_if_not_exists
|
||||
from abc import abstractmethod
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ class ReleaseApi(Api):
|
||||
tag = release["tag"]
|
||||
|
||||
release_path = join(path, repository_name)
|
||||
release_json = json.dumps(release)
|
||||
release_json = to_json(release)
|
||||
|
||||
create_if_not_exists(release_path)
|
||||
|
||||
|
@ -5,10 +5,13 @@ import os
|
||||
def write_json(text: str | dict | list, to, overwrite=True):
|
||||
if not os.path.exists(to) or overwrite:
|
||||
with open(to, "w") as f:
|
||||
if not isinstance(text, str):
|
||||
text = json.dumps(text)
|
||||
text = to_json(text)
|
||||
f.write(text)
|
||||
|
||||
def to_json(text: str | dict | list):
|
||||
if not isinstance(text, str):
|
||||
text = json.dumps(text, indent=2)
|
||||
return text
|
||||
|
||||
def read_json(path, default):
|
||||
if os.path.exists(path):
|
||||
|
Loading…
x
Reference in New Issue
Block a user