json.dumps(indent=2) (#17714)

This commit is contained in:
Kyle Altendorf
2024-03-18 10:26:13 -07:00
committed by GitHub
parent 3d984f5db4
commit 2eb3633bcb
8 changed files with 32 additions and 32 deletions
+1 -1
View File
@@ -198,7 +198,7 @@ if len(messages) > 0:
configuration_json = json.dumps(configuration)
for line in json.dumps(configuration, indent=4).splitlines():
for line in json.dumps(configuration, indent=2).splitlines():
logging.info(line)
print(f"{configuration_json}")
+1 -1
View File
@@ -31,7 +31,7 @@ class BalanceCheckingError(Exception):
self.errors = errors
def __repr__(self) -> str:
return json.dumps(self.errors, indent=4)
return json.dumps(self.errors, indent=2)
def __str__(self) -> str:
return self.__repr__()
+1 -1
View File
@@ -86,7 +86,7 @@ class CostLogger:
"standard cost": self.cost_dict,
"no puzzle reveals": self.cost_dict_no_puzs,
}
return json.dumps(merged_dict, indent=4)
return json.dumps(merged_dict, indent=2)
@streamable
+23 -23
View File
@@ -46,7 +46,7 @@ async def create_data_store_cmd(
final_fee = None if fee is None else uint64(int(Decimal(fee) * units["chia"]))
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.create_data_store(fee=final_fee, verbose=verbose)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def get_value_cmd(
@@ -61,7 +61,7 @@ async def get_value_cmd(
root_hash_bytes = None if root_hash is None else bytes32.from_hexstr(root_hash)
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.get_value(store_id=store_id_bytes, key=key_bytes, root_hash=root_hash_bytes)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def update_data_store_cmd(
@@ -84,7 +84,7 @@ async def update_data_store_cmd(
fee=final_fee,
submit_on_chain=submit_on_chain,
)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
return res
@@ -104,7 +104,7 @@ async def submit_pending_root_cmd(
store_id=store_id_bytes,
fee=final_fee,
)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
return res
@@ -125,7 +125,7 @@ async def get_keys_cmd(
res = await client.get_keys(
store_id=store_id_bytes, root_hash=root_hash_bytes, page=page, max_page_size=max_page_size
)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
return res
@@ -146,7 +146,7 @@ async def get_keys_values_cmd(
res = await client.get_keys_values(
store_id=store_id_bytes, root_hash=root_hash_bytes, page=page, max_page_size=max_page_size
)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
return res
@@ -159,7 +159,7 @@ async def get_root_cmd(
store_id_bytes = bytes32.from_hexstr(store_id)
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.get_root(store_id=store_id_bytes)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def subscribe_cmd(
@@ -171,7 +171,7 @@ async def subscribe_cmd(
store_id_bytes = bytes32.from_hexstr(store_id)
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.subscribe(store_id=store_id_bytes, urls=urls)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def unsubscribe_cmd(
@@ -183,7 +183,7 @@ async def unsubscribe_cmd(
store_id_bytes = bytes32.from_hexstr(store_id)
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.unsubscribe(store_id=store_id_bytes, retain=retain)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def remove_subscriptions_cmd(
@@ -195,7 +195,7 @@ async def remove_subscriptions_cmd(
store_id_bytes = bytes32.from_hexstr(store_id)
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.remove_subscriptions(store_id=store_id_bytes, urls=urls)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def get_kv_diff_cmd(
@@ -217,7 +217,7 @@ async def get_kv_diff_cmd(
res = await client.get_kv_diff(
store_id=store_id_bytes, hash_1=hash_1_bytes, hash_2=hash_2_bytes, page=page, max_page_size=max_page_size
)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
return res
@@ -230,7 +230,7 @@ async def get_root_history_cmd(
store_id_bytes = bytes32.from_hexstr(store_id)
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.get_root_history(store_id=store_id_bytes)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def add_missing_files_cmd(
@@ -246,7 +246,7 @@ async def add_missing_files_cmd(
overwrite=overwrite,
foldername=foldername,
)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def add_mirror_cmd(
@@ -266,7 +266,7 @@ async def add_mirror_cmd(
amount=amount,
fee=final_fee,
)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def delete_mirror_cmd(
@@ -282,7 +282,7 @@ async def delete_mirror_cmd(
coin_id=coin_id_bytes,
fee=final_fee,
)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def get_mirrors_cmd(
@@ -293,7 +293,7 @@ async def get_mirrors_cmd(
store_id_bytes = bytes32.from_hexstr(store_id)
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.get_mirrors(store_id=store_id_bytes)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def get_subscriptions_cmd(
@@ -302,7 +302,7 @@ async def get_subscriptions_cmd(
) -> None:
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.get_subscriptions()
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def get_owned_stores_cmd(
@@ -311,7 +311,7 @@ async def get_owned_stores_cmd(
) -> None:
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.get_owned_stores()
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def get_sync_status_cmd(
@@ -322,13 +322,13 @@ async def get_sync_status_cmd(
store_id_bytes = bytes32.from_hexstr(store_id)
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.get_sync_status(store_id=store_id_bytes)
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def check_plugins_cmd(rpc_port: Optional[int]) -> None:
async with get_client(rpc_port=rpc_port) as (client, _):
res = await client.check_plugins()
print(json.dumps(res, indent=4, sort_keys=True))
print(json.dumps(res, indent=2, sort_keys=True))
async def clear_pending_roots(
@@ -339,7 +339,7 @@ async def clear_pending_roots(
) -> Dict[str, Any]:
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint, root_path=root_path) as (client, _):
result = await client.clear_pending_roots(store_id=store_id)
print(json.dumps(result, indent=4, sort_keys=True))
print(json.dumps(result, indent=2, sort_keys=True))
return result
@@ -354,7 +354,7 @@ async def get_proof_cmd(
result = dict()
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint, root_path=root_path) as (client, _):
result = await client.get_proof(store_id=store_id, keys=[hexstr_to_bytes(key) for key in key_strings])
print(json.dumps(result, indent=4, sort_keys=True))
print(json.dumps(result, indent=2, sort_keys=True))
return result
@@ -368,6 +368,6 @@ async def verify_proof_cmd(
result = dict()
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint, root_path=root_path) as (client, _):
result = await client.verify_proof(proof=proof)
print(json.dumps(result, indent=4, sort_keys=True))
print(json.dumps(result, indent=2, sort_keys=True))
return result
+2 -2
View File
@@ -78,7 +78,7 @@ async def call_daemon_command(
def print_result(json_dict: Dict[str, Any]) -> None:
print(json.dumps(json_dict, indent=4, sort_keys=True))
print(json.dumps(json_dict, indent=2, sort_keys=True))
def get_routes(service: str, config: Dict[str, Any], quiet: bool = False) -> Dict[str, Any]:
@@ -126,7 +126,7 @@ def status_cmd(json_output: bool) -> None:
if json_output:
# If --json-output option is used, print the status data as JSON
print(json.dumps(status_data, indent=4))
print(json.dumps(status_data, indent=2))
else:
print("╭──────────────┬───────────╮")
print_row("SERVICE", "STATUS")
+2 -2
View File
@@ -47,12 +47,12 @@ def marshal() -> RouteDecorator:
async def wrapper(self: object, request: Dict[str, object]) -> Dict[str, object]:
# import json
# name = route.__name__
# print(f"\n ==== {name} request.json\n{json.dumps(request, indent=4)}")
# print(f"\n ==== {name} request.json\n{json.dumps(request, indent=2)}")
unmarshalled_request = request_class.unmarshal(request)
response = await route(self, request=unmarshalled_request)
marshalled_response = response.marshal()
# print(f"\n ==== {name} response.json\n{json.dumps(marshalled_response, indent=4)}")
# print(f"\n ==== {name} response.json\n{json.dumps(marshalled_response, indent=2)}")
return marshalled_response
+1 -1
View File
@@ -67,7 +67,7 @@ def update_version(package_json_path: str):
data["version"] = get_chia_version()
with open(package_json_path, "w") as w:
json.dump(data, indent=4, fp=w)
json.dump(data, indent=2, fp=w)
if __name__ == "__main__":
+1 -1
View File
@@ -98,7 +98,7 @@ def load_cache(file: typing.IO[str]) -> Cache:
def dump_cache(cache: Cache, file: typing.IO[str]) -> None:
json.dump(cache, file, indent=4)
json.dump(cache, file, indent=2)
def generate_hash_bytes(hex_bytes: bytes) -> bytes32: