Skip to content

Commit

Permalink
change getting error codes to a dict so its easier to grab lines
Browse files Browse the repository at this point in the history
  • Loading branch information
mikey0000 committed Oct 30, 2024
1 parent 0e4e02a commit 067ae58
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pymammotion/http/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ def __init__(self, response: Response) -> None:
self.msg = response.msg
self.code = response.code

async def get_all_error_codes(self) -> list[ErrorInfo]:
async def get_all_error_codes(self) -> dict[str, ErrorInfo]:
async with ClientSession(MAMMOTION_API_DOMAIN) as session:
async with session.post(
"/user-server/v1/code/record/export-data",
headers=self._headers,
) as resp:
data = await resp.json()
reader = csv.DictReader(data.get("data", "").split("\n"), delimiter=",")
codes = []
codes = dict()
for row in reader:
codes.append(ErrorInfo(**cast(dict, row)))
error_info = ErrorInfo(**cast(dict, row))
codes[error_info.code] = error_info
return codes

async def oauth_check(self) -> None:
Expand Down

0 comments on commit 067ae58

Please sign in to comment.