reformatted all files to use the Black formatting style
This commit is contained in:
@@ -4,7 +4,7 @@ from API import APIError
|
||||
# noinspection PyPep8
|
||||
async def safe_parse_api_data(data: dict or list, *path: str or int, idx: int = 0):
|
||||
path = [*path]
|
||||
if len(path) == idx+1:
|
||||
if len(path) == idx + 1:
|
||||
if isinstance(path[idx], str):
|
||||
if isinstance(data, dict):
|
||||
if path[idx] in data.keys():
|
||||
@@ -17,34 +17,50 @@ async def safe_parse_api_data(data: dict or list, *path: str or int, idx: int =
|
||||
if isinstance(path[idx], str):
|
||||
if isinstance(data, dict):
|
||||
if path[idx] in data.keys():
|
||||
parsed_data = await safe_parse_api_data(data[path[idx]], idx=idx+1, *path)
|
||||
parsed_data = await safe_parse_api_data(
|
||||
data[path[idx]], idx=idx + 1, *path
|
||||
)
|
||||
# has to be == None, or else it fails on 0.0 hashrates
|
||||
# noinspection PyPep8
|
||||
if parsed_data == None:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return parsed_data
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
elif isinstance(path[idx], int):
|
||||
if isinstance(data, list):
|
||||
if len(data) > path[idx]:
|
||||
parsed_data = await safe_parse_api_data(data[path[idx]], idx=idx+1, *path)
|
||||
parsed_data = await safe_parse_api_data(
|
||||
data[path[idx]], idx=idx + 1, *path
|
||||
)
|
||||
# has to be == None, or else it fails on 0.0 hashrates
|
||||
# noinspection PyPep8
|
||||
if parsed_data == None:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return parsed_data
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
else:
|
||||
if idx == 0:
|
||||
raise APIError(f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}")
|
||||
raise APIError(
|
||||
f"Data parsing failed on path index {idx} - \nKey: {path[idx]} \nData: {data}"
|
||||
)
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user