reformat/refactor

This commit is contained in:
2025-04-26 21:59:46 -04:00
parent 5bde6ac880
commit a433dc2fb5
14 changed files with 150 additions and 107 deletions

View File

@ -79,11 +79,12 @@ class CatboxAsync:
) as request:
request.raise_for_status()
return await request.text()
except:
except Exception as e:
logging.debug("Exception: %s", str(e))
traceback.print_exc()
return None
finally:
try:
fileContents.close()
except:
except: # noqa
return None

View File

@ -75,7 +75,7 @@ class JesusMemeGenerator:
logging.info("Meme upload failed!")
return None
return meme_link
except:
print(traceback.format_exc())
pass
except Exception as e:
logging.debug("Exception: %s", str(e))
traceback.print_exc()
return None

View File

@ -94,12 +94,13 @@ class LitterboxAsync:
) as request:
request.raise_for_status()
return await request.text()
except:
except Exception as e:
logging.debug("Exception: %s", str(e))
traceback.print_exc()
return None
finally:
if isinstance(file, BufferedReader):
try:
file.close()
except:
except: # noqa
return None

View File

@ -149,7 +149,7 @@ class DB:
Returns:
str
"""
if not flag in range(-1, 2):
if flag not in range(-1, 2):
raise LoveHateException(
f"Invalid flag {flag} specified, is this love (1), hate (-1), or dontcare? (0)"
)

View File

@ -449,7 +449,8 @@ class Util:
if not fact:
raise BaseException("RandFact Src 1 Failed")
return fact
except:
except Exception as e:
logging.debug("Exception: %s", str(e))
async with await client.get(
facts_backup_url, timeout=ClientTimeout(connect=5, sock_read=5)
) as request:
@ -502,7 +503,8 @@ class Util:
self.LAST_5_COFFEES.pop() # Store no more than 5 of the last served coffees
self.LAST_5_COFFEES.append(randomCoffee)
return randomCoffee
except:
except Exception as e:
logging.debug("Exception: %s", str(e))
traceback.print_exc()
return None

View File

@ -89,7 +89,8 @@ class Utility:
song.split(search_split_by)[2:]
) # Lyric text from split index 2 and beyond
return (search_artist, search_song, search_subsearch)
except:
except Exception as e:
logging.debug("Exception: %s", str(e))
traceback.print_exc()
return False