Skip to content

Commit

Permalink
Auto-format code [skip actions]
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Nov 29, 2024
1 parent b9a7f1f commit 1d44956
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 53 deletions.
6 changes: 3 additions & 3 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def arg_parser(items, arg_base):
if part in arg_base:
if arg_start == -1:
arg_start = i
if i + 1 == t and part in bool_arg_set or part in ["-s", "-j"]:
if (i + 1 == t and part in bool_arg_set) or part in ["-s", "-j"]:
arg_base[part] = True
else:
sub_list = []
Expand Down Expand Up @@ -525,8 +525,8 @@ async def checking_access(user_id, button=None):
if DATABASE_URL:
data["time"] = await DbManager().get_token_expiry(user_id)
expire = data.get("time")
is_expired = (
expire is None or expire is not None and (time() - expire) > token_timeout
is_expired = expire is None or (
expire is not None and (time() - expire) > token_timeout
)
if is_expired:
token = data["token"] if expire is None and "token" in data else str(uuid4())
Expand Down
25 changes: 8 additions & 17 deletions bot/helper/ext_utils/files_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,8 @@ async def split_file(
i=1,
multi_streams=True,
):
if (
listener.suproc == "cancelled"
or listener.suproc is not None
and listener.suproc.returncode == -9
if listener.suproc == "cancelled" or (
listener.suproc is not None and listener.suproc.returncode == -9
):
return False
if listener.seed and not listener.newDir:
Expand Down Expand Up @@ -353,10 +351,8 @@ async def split_file(
if not multi_streams:
del cmd[10]
del cmd[10]
if (
listener.suproc == "cancelled"
or listener.suproc is not None
and listener.suproc.returncode == -9
if listener.suproc == "cancelled" or (
listener.suproc is not None and listener.suproc.returncode == -9
):
return False
listener.suproc = await create_subprocess_exec(*cmd, stderr=PIPE)
Expand Down Expand Up @@ -629,10 +625,8 @@ async def clean_unwanted(path):
LOGGER.info(f"Cleaning unwanted files/folders: {path}")
for dirpath, _, files in await sync_to_async(walk, path, topdown=False):
for filee in files:
if (
filee.endswith(".!qB")
or filee.endswith(".parts")
and filee.startswith(".")
if filee.endswith(".!qB") or (
filee.endswith(".parts") and filee.startswith(".")
):
await aioremove(ospath.join(dirpath, filee))
if dirpath.endswith((".unwanted", "splited_files", "copied")):
Expand Down Expand Up @@ -683,11 +677,8 @@ def get_mime_type(file_path):
def check_storage_threshold(size, threshold, arch=False, alloc=False):
free = disk_usage("/usr/src/app/downloads/").free
if not alloc:
if (
not arch
and free - size < threshold
or arch
and free - (size * 2) < threshold
if (not arch and free - size < threshold) or (
arch and free - (size * 2) < threshold
):
return False
elif not arch:
Expand Down
12 changes: 4 additions & 8 deletions bot/helper/ext_utils/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ async def limit_checker(
):
LOGGER.info("Checking limit")
user_id = listener.message.from_user.id
if (
user_id == OWNER_ID
or user_id in user_data
and user_data[user_id].get("is_sudo")
if user_id == OWNER_ID or (
user_id in user_data and user_data[user_id].get("is_sudo")
):
return None
if await isAdmin(listener.message):
Expand Down Expand Up @@ -235,10 +233,8 @@ async def task_utils(message):
_msg, button = await BotPm_check(message, button)
if _msg:
msg.append(_msg)
if (
user_id == OWNER_ID
or user_id in user_data
and user_data[user_id].get("is_sudo")
if user_id == OWNER_ID or (
user_id in user_data and user_data[user_id].get("is_sudo")
):
return msg, button
if admin:
Expand Down
17 changes: 6 additions & 11 deletions bot/helper/listeners/tasks_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,8 @@ async def on_download_complete(self):
multi_links = False
while True:
if self.same_dir:
if (
self.same_dir["total"] in [1, 0]
or self.same_dir["total"] > 1
and len(self.same_dir["tasks"]) > 1
if self.same_dir["total"] in [1, 0] or (
self.same_dir["total"] > 1 and len(self.same_dir["tasks"]) > 1
):
break
else:
Expand Down Expand Up @@ -228,10 +226,8 @@ async def on_download_complete(self):
walk, dl_path, topdown=False
):
for file_ in files:
if (
is_first_archive_split(file_)
or is_archive(file_)
and not file_.endswith(".rar")
if is_first_archive_split(file_) or (
is_archive(file_) and not file_.endswith(".rar")
):
f_path = ospath.join(dirpath, file_)
t_path = (
Expand All @@ -250,9 +246,8 @@ async def on_download_complete(self):
]
if not pswd:
del cmd[2]
if (
self.suproc == "cancelled"
or self.suproc is not None
if self.suproc == "cancelled" or (
self.suproc is not None
and self.suproc.returncode == -9
):
return
Expand Down
6 changes: 2 additions & 4 deletions bot/helper/mirror_leech_utils/download_utils/mega_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ def onRequestFinish(self, api, request, error):
self.node = api.getRootNode()
self.__name = self.node.getName()
LOGGER.info(f"Node Name: {self.node.getName()}")
if (
request_type not in self._NO_EVENT_ON
or self.node
and "cloud drive" not in self.__name.lower()
if request_type not in self._NO_EVENT_ON or (
self.node and "cloud drive" not in self.__name.lower()
):
self.continue_event.set()

Expand Down
3 changes: 1 addition & 2 deletions bot/helper/mirror_leech_utils/rclone_utils/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ async def get_path_buttons(self):
if (
self.path
or len(self.__sections) > 1
or self.__rc_user
and self.__rc_owner
or (self.__rc_user and self.__rc_owner)
):
buttons.callback("Back", "rcq back pa", position="footer")
if self.path:
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/telegram_helper/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def sudo_user(self, _, message):
user = message.from_user or message.sender_chat
uid = user.id
return bool(
uid == OWNER_ID or uid in user_data and user_data[uid].get("is_sudo")
uid == OWNER_ID or (uid in user_data and user_data[uid].get("is_sudo"))
)

sudo = create(sudo_user)
2 changes: 1 addition & 1 deletion bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ async def event_filter(_, __, event):
return bool(
user.id == query.from_user.id
and event.chat.id == chat_id
and (event.text or event.document and document)
and (event.text or (event.document and document))
)

handler = client.add_handler(
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/mirror_leech.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ async def __run_multi():
await delete_message(process_msg)

if not is_leech:
if config_dict["DEFAULT_UPLOAD"] == "rc" and not up or up == "rc":
if (config_dict["DEFAULT_UPLOAD"] == "rc" and not up) or up == "rc":
up = config_dict["RCLONE_PATH"]
if not up and config_dict["DEFAULT_UPLOAD"] == "gd":
up = "gd"
Expand Down
6 changes: 2 additions & 4 deletions bot/modules/users_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,8 @@ async def get_user_settings(from_user, key=None, edit_type=None, edit_mode=None)
buttons.callback("Close", f"userset {user_id} close", "footer")
button = buttons.column(2)
elif key == "leech":
if (
user_dict.get("as_doc", False)
or "as_doc" not in user_dict
and config_dict["AS_DOCUMENT"]
if user_dict.get("as_doc", False) or (
"as_doc" not in user_dict and config_dict["AS_DOCUMENT"]
):
ltype = "DOCUMENT"
buttons.callback("Send As Media", f"userset {user_id} doc")
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/ytdlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ async def __run_multi():
return None

if not is_leech:
if config_dict["DEFAULT_UPLOAD"] == "rc" and not up or up == "rc":
if (config_dict["DEFAULT_UPLOAD"] == "rc" and not up) or up == "rc":
up = config_dict["RCLONE_PATH"]
if not up and config_dict["DEFAULT_UPLOAD"] == "gd":
up = "gd"
Expand Down

0 comments on commit 1d44956

Please sign in to comment.