Skip to content

Commit

Permalink
Fix: Copy files while retaining file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
WhoIsConch committed Apr 26, 2022
1 parent 019db54 commit 66a67f2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion uwuinator-prod/uwuinator_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,36 @@ def size(self) -> int:
return self.file_size

def get_filled(self) -> str:
'''
Gets the total space filled by the UwUinator.
'''
units = ('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')

power = int(math.log(self.size * self.counter, 1024))

return f"{self.size * self.counter / (1024 ** power):.2f} {units[power]}"

def _get_mbps(self, file_amt: int, time: int) -> float:
'''
Gets the average write speed of the UwUinator.
'''
return round((file_amt * ((self.size / 1024) / 1024)) / (time * 60), 2)

async def copy(self) -> bool:
'''
Copies the file to the specified path.
'''
try:
with open(f"{self.path}\\UwU-{uuid.uuid4()}.jpg", "wb") as f:
with open(f"{self.path}\\UwU-{uuid.uuid4()}.{self.file.split('\\')[-1][-3:]}", "wb") as f:
f.write(self.data)
return True
except:
return False

async def uwuinator(self) -> None:
'''
The main function of the UwUinator.
'''
self.counter = 0

while True:
Expand Down Expand Up @@ -110,6 +122,9 @@ async def uwuinator(self) -> None:

@classmethod
async def start(cls) -> None:
'''
Starts the UwUinator.
'''
print("Welcome to the UwUinator! v.1.5.1")

while True:
Expand Down

0 comments on commit 66a67f2

Please sign in to comment.