-
Notifications
You must be signed in to change notification settings - Fork 464
ROGUE v2 (Sourcery refactored) #78
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,7 +396,7 @@ def _download_file(self, path: str, name: str, **kwargs) -> None: | |
d_file_obj = MediaIoBaseDownload(d_f, request, chunksize=50 * 1024 * 1024) | ||
c_time = time.time() | ||
done = False | ||
while done is False: | ||
while not done: | ||
status, done = d_file_obj.next_chunk(num_retries=5) | ||
if self._is_canceled: | ||
raise ProcessCanceled | ||
|
@@ -756,12 +756,11 @@ def _get_file_id(self, filter_str: bool = False) -> tuple: | |
link = self._message.filtered_input_str | ||
found = _GDRIVE_ID.search(link) | ||
if found and "folder" in link: | ||
out = (found.group(1), "folder") | ||
return found.group(1), "folder" | ||
elif found: | ||
out = (found.group(1), "file") | ||
return found.group(1), "file" | ||
else: | ||
out = (link, "unknown") | ||
return out | ||
return link, "unknown" | ||
Comment on lines
-759
to
+763
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
async def setup(self) -> None: | ||
""" Setup GDrive """ | ||
|
@@ -933,7 +932,7 @@ async def upload(self) -> None: | |
except Exception as e_e: | ||
await self._message.err(e_e) | ||
return | ||
file_path = dl_loc if dl_loc else self._message.input_str | ||
file_path = dl_loc or self._message.input_str | ||
Comment on lines
-936
to
+935
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
if not os.path.exists(file_path): | ||
await self._message.err("invalid file path provided?") | ||
return | ||
|
@@ -964,7 +963,7 @@ async def upload(self) -> None: | |
out = f"**ERROR** : `{self._output._get_reason()}`" # pylint: disable=protected-access | ||
elif self._output is not None and not self._is_canceled: | ||
out = f"**Uploaded Successfully** __in {m_s} seconds__\n\n{self._output}" | ||
elif self._output is not None and self._is_canceled: | ||
elif self._output is not None: | ||
out = self._output | ||
else: | ||
out = "`failed to upload.. check logs?`" | ||
|
@@ -994,7 +993,7 @@ async def download(self) -> None: | |
out = ( | ||
f"**Downloaded Successfully** __in {m_s} seconds__\n\n`{self._output}`" | ||
) | ||
elif self._output is not None and self._is_canceled: | ||
elif self._output is not None: | ||
Comment on lines
-997
to
+996
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
out = self._output | ||
else: | ||
out = "`failed to download.. check logs?`" | ||
|
@@ -1025,7 +1024,7 @@ async def copy(self) -> None: | |
out = f"**ERROR** : `{self._output._get_reason()}`" # pylint: disable=protected-access | ||
elif self._output is not None and not self._is_canceled: | ||
out = f"**Copied Successfully** __in {m_s} seconds__\n\n{self._output}" | ||
elif self._output is not None and self._is_canceled: | ||
elif self._output is not None: | ||
Comment on lines
-1028
to
+1027
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
out = self._output | ||
else: | ||
out = "`failed to copy.. check logs?`" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
_GDrive._download_file
refactored with the following changes:simplify-boolean-comparison
)