Skip to content

Commit 91d3508

Browse files
committed
Rename encode/decode to encode/decode_file_id
1 parent 92c1b48 commit 91d3508

File tree

13 files changed

+26
-26
lines changed

13 files changed

+26
-26
lines changed

pyrogram/client/ext/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from ...api import types
2828

2929

30-
def decode(s: str) -> bytes:
30+
def decode_file_id(s: str) -> bytes:
3131
s = base64.urlsafe_b64decode(s + "=" * (-len(s) % 4))
3232
r = b""
3333

@@ -53,7 +53,7 @@ def decode(s: str) -> bytes:
5353
return r
5454

5555

56-
def encode(s: bytes) -> str:
56+
def encode_file_id(s: bytes) -> str:
5757
r = b""
5858
n = 0
5959

@@ -97,7 +97,7 @@ def get_input_media_from_file_id(
9797
expected_media_type: int = None
9898
) -> Union[types.InputMediaPhoto, types.InputMediaDocument]:
9999
try:
100-
decoded = decode(file_id_str)
100+
decoded = decode_file_id(file_id_str)
101101
except Exception:
102102
raise ValueError("Failed to decode file_id: {}".format(file_id_str))
103103
else:

pyrogram/client/methods/messages/download_media.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def get_existing_attributes() -> dict:
141141
return dict(filter(lambda x: x[1] is not None, data.__dict__.items()))
142142

143143
try:
144-
decoded = utils.decode(file_id_str)
144+
decoded = utils.decode_file_id(file_id_str)
145145
media_type = decoded[0]
146146

147147
if media_type == 1:

pyrogram/client/methods/users/delete_profile_photos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def delete_profile_photos(
5555
input_photos = []
5656

5757
for photo_id in photo_ids:
58-
unpacked = unpack("<iiqqc", utils.decode(photo_id))
58+
unpacked = unpack("<iiqqc", utils.decode_file_id(photo_id))
5959

6060
input_photos.append(
6161
types.InputPhoto(

pyrogram/client/types/messages_and_media/animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from pyrogram.api import types
2424
from .thumbnail import Thumbnail
2525
from ..object import Object
26-
from ...ext.utils import encode, encode_file_ref
26+
from ...ext.utils import encode_file_id, encode_file_ref
2727

2828

2929
class Animation(Object):
@@ -97,7 +97,7 @@ def _parse(
9797
file_name: str
9898
) -> "Animation":
9999
return Animation(
100-
file_id=encode(
100+
file_id=encode_file_id(
101101
pack(
102102
"<iiqq",
103103
10,

pyrogram/client/types/messages_and_media/audio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from pyrogram.api import types
2424
from .thumbnail import Thumbnail
2525
from ..object import Object
26-
from ...ext.utils import encode, encode_file_ref
26+
from ...ext.utils import encode_file_id, encode_file_ref
2727

2828

2929
class Audio(Object):
@@ -97,7 +97,7 @@ def _parse(
9797
file_name: str
9898
) -> "Audio":
9999
return Audio(
100-
file_id=encode(
100+
file_id=encode_file_id(
101101
pack(
102102
"<iiqq",
103103
9,

pyrogram/client/types/messages_and_media/document.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from pyrogram.api import types
2424
from .thumbnail import Thumbnail
2525
from ..object import Object
26-
from ...ext.utils import encode, encode_file_ref
26+
from ...ext.utils import encode_file_id, encode_file_ref
2727

2828

2929
class Document(Object):
@@ -77,7 +77,7 @@ def __init__(
7777
@staticmethod
7878
def _parse(client, document: types.Document, file_name: str) -> "Document":
7979
return Document(
80-
file_id=encode(
80+
file_id=encode_file_id(
8181
pack(
8282
"<iiqq",
8383
5,

pyrogram/client/types/messages_and_media/photo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from pyrogram.api import types
2424
from .thumbnail import Thumbnail
2525
from ..object import Object
26-
from ...ext.utils import encode, encode_file_ref
26+
from ...ext.utils import encode_file_id, encode_file_ref
2727

2828

2929
class Photo(Object):
@@ -80,7 +80,7 @@ def _parse(client, photo: types.Photo) -> "Photo":
8080
big = photo.sizes[-1]
8181

8282
return Photo(
83-
file_id=encode(
83+
file_id=encode_file_id(
8484
pack(
8585
"<iiqqqiiii",
8686
2, photo.dc_id, photo.id, photo.access_hash,

pyrogram/client/types/messages_and_media/sticker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from pyrogram.errors import StickersetInvalid
2626
from .thumbnail import Thumbnail
2727
from ..object import Object
28-
from ...ext.utils import encode, encode_file_ref
28+
from ...ext.utils import encode_file_id, encode_file_ref
2929

3030

3131
class Sticker(Object):
@@ -131,7 +131,7 @@ def _parse(client, sticker: types.Document, image_size_attributes: types.Documen
131131
set_name = None
132132

133133
return Sticker(
134-
file_id=encode(
134+
file_id=encode_file_id(
135135
pack(
136136
"<iiqq",
137137
8,

pyrogram/client/types/messages_and_media/thumbnail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import pyrogram
2323
from pyrogram.api import types
24-
from pyrogram.client.ext.utils import encode
24+
from pyrogram.client.ext.utils import encode_file_id
2525
from .stripped_thumbnail import StrippedThumbnail
2626
from ..object import Object
2727

@@ -85,7 +85,7 @@ def _parse(
8585
if isinstance(thumbnail, types.PhotoSize):
8686
thumbnails.append(
8787
Thumbnail(
88-
file_id=encode(
88+
file_id=encode_file_id(
8989
pack(
9090
"<iiqqqiiii",
9191
media_type, media.dc_id, media.id, media.access_hash,

pyrogram/client/types/messages_and_media/video.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from pyrogram.api import types
2424
from .thumbnail import Thumbnail
2525
from ..object import Object
26-
from ...ext.utils import encode, encode_file_ref
26+
from ...ext.utils import encode_file_id, encode_file_ref
2727

2828

2929
class Video(Object):
@@ -102,7 +102,7 @@ def _parse(
102102
file_name: str
103103
) -> "Video":
104104
return Video(
105-
file_id=encode(
105+
file_id=encode_file_id(
106106
pack(
107107
"<iiqq",
108108
4,

0 commit comments

Comments
 (0)