From f38113b8120e95a58756eac90bbf8a0980a92608 Mon Sep 17 00:00:00 2001 From: ConchDev Date: Fri, 29 Apr 2022 09:56:41 -0400 Subject: [PATCH] Fix: ValueErrors --- uwuinator-prod/uwuinator_5.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/uwuinator-prod/uwuinator_5.py b/uwuinator-prod/uwuinator_5.py index 234e2c3..0ddec09 100644 --- a/uwuinator-prod/uwuinator_5.py +++ b/uwuinator-prod/uwuinator_5.py @@ -75,8 +75,9 @@ async def copy(self) -> bool: ''' Copies the file to the specified path. ''' + path = self.path + "\\UwU-" + str(uuid.uuid4()) + "." + str(self.file.split('\\')[-1].split('.')[-1]) try: - with open(f"{self.path}\\UwU-{uuid.uuid4()}.{self.file.split('\\')[-1].split('.')[-1]}", "wb") as f: + with open(path, "wb") as f: f.write(self.data) return True except: @@ -140,18 +141,22 @@ async def start(cls) -> None: else: break - file = os.path.exists(os.getcwd() + "\\img.jpg") - if not file: + # Get the path to img.jpg relative to the file + fp = os.path.join(os.path.dirname(__file__), "img.jpg") + + file_exists = os.path.exists(fp) + + if not file_exists: while True: - file = input("Image file not found. Enter the path to the image file now: ") + fp = input("Image file not found. Enter the path to the image file now: ") - if not os.path.exists(file): + if not os.path.exists(fp): continue else: break - uwu = cls(path, file) + uwu = cls(path, fp) print("UwUinating...") await uwu.uwuinator()