From eda0f959dd38bf8bbe708894f15cf3f234d1043f Mon Sep 17 00:00:00 2001 From: timka Date: Mon, 8 Jan 2024 20:41:34 +0300 Subject: [PATCH] fix invalid card number handler --- utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index d8f8982..6ba869a 100644 --- a/utils.py +++ b/utils.py @@ -16,7 +16,10 @@ async def tk_balance(card_number: int): file = open("temp.xml", "w+") file.write(text) file.close() - balance = ElementTree.parse("temp.xml").findtext(".//pbtext").replace("Билет длительного пользования", "").replace(" руб.", "") + try: + balance = ElementTree.parse("temp.xml").findtext(".//pbtext").replace("Билет длительного пользования", "").replace(" руб.", "") + except AttributeError: + return if not balance: return return int(balance)