Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
'Refactored by Sourcery' (#78)
Browse files Browse the repository at this point in the history
Co-authored-by: Sourcery AI <>
  • Loading branch information
sourcery-ai[bot] authored Nov 29, 2020
1 parent 64f9298 commit 4cf3a05
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions userge/plugins/misc/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

async def setup(self) -> None:
""" Setup GDrive """
Expand Down Expand Up @@ -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
if not os.path.exists(file_path):
await self._message.err("invalid file path provided?")
return
Expand Down Expand Up @@ -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?`"
Expand Down Expand Up @@ -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:
out = self._output
else:
out = "`failed to download.. check logs?`"
Expand Down Expand Up @@ -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:
out = self._output
else:
out = "`failed to copy.. check logs?`"
Expand Down

0 comments on commit 4cf3a05

Please sign in to comment.