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

ROGUE v2 (Sourcery refactored) #78

Merged
merged 1 commit into from
Nov 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor Author

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 comparison to boolean (simplify-boolean-comparison)

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"
Comment on lines -759 to +763
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Worker._get_file_id refactored with the following changes:

  • Lift return into if (lift-return-into-if)


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
Comment on lines -936 to +935
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Worker.upload refactored with the following changes:

  • Remove redundant conditional (remove-redundant-if)
  • Simplify if expression by using or (or-if-exp-identity)

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:
Comment on lines -997 to +996
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Worker.download refactored with the following changes:

  • Remove redundant conditional (remove-redundant-if)

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:
Comment on lines -1028 to +1027
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Worker.copy refactored with the following changes:

  • Remove redundant conditional (remove-redundant-if)

out = self._output
else:
out = "`failed to copy.. check logs?`"
Expand Down