Skip to content

Commit

Permalink
black code format + bump
Browse files Browse the repository at this point in the history
Signed-off-by: eyMarv <[email protected]>
  • Loading branch information
eyMarv committed Mar 2, 2024
1 parent 06755b8 commit 5df01f6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyrogram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# along with pyroblack. If not, see <http://www.gnu.org/licenses/>.

__fork_name__ = "pyroblack"
__version__ = "2.3.45"
__version__ = "2.3.46"
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
__copyright__ = "# Copyright (C) 2024-present eyMarv <https://github.com/eyMarv>"

Expand Down
32 changes: 20 additions & 12 deletions pyrogram/methods/advanced/save_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ async def worker(session):
elif isinstance(path, io.IOBase):
fp = path
else:
raise ValueError("Invalid file. Expected a file path as string or a binary (not text) file pointer")
raise ValueError(
"Invalid file. Expected a file path as string or a binary (not text) file pointer"
)

file_name = getattr(fp, "name", "file.jpg")

Expand All @@ -131,7 +133,9 @@ async def worker(session):
file_size_limit_mib = 4000 if self.me.is_premium else 2000

if file_size > file_size_limit_mib * 1024 * 1024:
raise ValueError(f"Can't upload files bigger than {file_size_limit_mib} MiB")
raise ValueError(
f"Can't upload files bigger than {file_size_limit_mib} MiB"
)

file_total_parts = int(math.ceil(file_size / part_size))
is_big = file_size > 10 * 1024 * 1024
Expand All @@ -140,10 +144,15 @@ async def worker(session):
file_id = file_id or self.rnd_id()
md5_sum = md5() if not is_big and not is_missing_part else None
session = Session(
self, await self.storage.dc_id(), await self.storage.auth_key(),
await self.storage.test_mode(), is_media=True
self,
await self.storage.dc_id(),
await self.storage.auth_key(),
await self.storage.test_mode(),
is_media=True,
)
workers = [self.loop.create_task(worker(session)) for _ in range(workers_count)]
workers = [
self.loop.create_task(worker(session)) for _ in range(workers_count)
]
queue = asyncio.Queue(1)

try:
Expand All @@ -156,21 +165,21 @@ async def worker(session):

if not chunk:
if not is_big and not is_missing_part:
md5_sum = "".join([hex(i)[2:].zfill(2) for i in md5_sum.digest()])
md5_sum = "".join(
[hex(i)[2:].zfill(2) for i in md5_sum.digest()]
)
break

if is_big:
rpc = raw.functions.upload.SaveBigFilePart(
file_id=file_id,
file_part=file_part,
file_total_parts=file_total_parts,
bytes=chunk
bytes=chunk,
)
else:
rpc = raw.functions.upload.SaveFilePart(
file_id=file_id,
file_part=file_part,
bytes=chunk
file_id=file_id, file_part=file_part, bytes=chunk
)

await queue.put(rpc)
Expand All @@ -188,7 +197,7 @@ async def worker(session):
progress,
min(file_part * part_size, file_size),
file_size,
*progress_args
*progress_args,
)

if inspect.iscoroutinefunction(progress):
Expand All @@ -205,7 +214,6 @@ async def worker(session):
id=file_id,
parts=file_total_parts,
name=file_name,

)
else:
return raw.types.InputFile(
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/chats/get_send_as_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ async def get_send_as_chats(

for p in r.peers:
if isinstance(p.peer, raw.types.PeerUser):
send_as_chats.append(types.Chat._parse_chat(self, users[p.peer.user_id]))
send_as_chats.append(
types.Chat._parse_chat(self, users[p.peer.user_id])
)
else:
send_as_chats.append(types.Chat._parse_chat(self, chats[p.peer.channel_id]))
send_as_chats.append(
types.Chat._parse_chat(self, chats[p.peer.channel_id])
)

return send_as_chats

0 comments on commit 5df01f6

Please sign in to comment.