Jedutils 0.2.4__tar.gz → 0.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Jedutils-0.2.4 → Jedutils-0.2.6}/Jedutils.egg-info/PKG-INFO +1 -1
- {Jedutils-0.2.4 → Jedutils-0.2.6}/Jedutils.egg-info/SOURCES.txt +1 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/PKG-INFO +1 -1
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/__init__.py +1 -1
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/base62/b62.py +2 -2
- Jedutils-0.2.6/jedutils/strings/__init__.py +12 -0
- Jedutils-0.2.6/jedutils/strings/_numerals.py +46 -0
- Jedutils-0.2.6/jedutils/strings/_random_string.py +43 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/tdlib/arithmetic.py +7 -7
- Jedutils-0.2.4/jedutils/strings/__init__.py +0 -4
- Jedutils-0.2.4/jedutils/strings/_random_string.py +0 -31
- {Jedutils-0.2.4 → Jedutils-0.2.6}/Jedutils.egg-info/dependency_links.txt +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/Jedutils.egg-info/requires.txt +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/Jedutils.egg-info/top_level.txt +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/LICENSE +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/MANIFEST.in +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/README.md +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/asyncio/__init__.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/asyncio/_async_redis_pipe.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/asyncio/_concurrency_manager.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/asyncio/_run_async.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/asyncio/_rwlock.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/asyncio/network/__init__.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/asyncio/network/_dl.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/base62/__init__.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/databases/__init__.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/databases/_in_memory.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/math/__init__.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/math/_number_formatter.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/strings/_chunked_text.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/jedutils/tdlib/__init__.py +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/setup.cfg +0 -0
- {Jedutils-0.2.4 → Jedutils-0.2.6}/setup.py +0 -0
|
@@ -23,6 +23,7 @@ jedutils/math/__init__.py
|
|
|
23
23
|
jedutils/math/_number_formatter.py
|
|
24
24
|
jedutils/strings/__init__.py
|
|
25
25
|
jedutils/strings/_chunked_text.py
|
|
26
|
+
jedutils/strings/_numerals.py
|
|
26
27
|
jedutils/strings/_random_string.py
|
|
27
28
|
jedutils/tdlib/__init__.py
|
|
28
29
|
jedutils/tdlib/arithmetic.py
|
|
@@ -5,7 +5,7 @@ BASE62_LOOKUP = {char: index for index, char in enumerate(BASE62_CHARS)}
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def b62encode(data: Union[bytes, int]) -> str:
|
|
8
|
-
"""
|
|
8
|
+
r"""
|
|
9
9
|
Encodes the given data into a base62 string
|
|
10
10
|
|
|
11
11
|
\Example:
|
|
@@ -40,7 +40,7 @@ def b62encode(data: Union[bytes, int]) -> str:
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
def b62decode(b62_string: str, as_int: bool = False) -> Union[bytes, int]:
|
|
43
|
-
"""
|
|
43
|
+
r"""
|
|
44
44
|
Decodes a Base62 encoded string
|
|
45
45
|
|
|
46
46
|
\Example:
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
__all__ = (
|
|
2
|
+
"random_string",
|
|
3
|
+
"random_string_urandom",
|
|
4
|
+
"random_hex_string",
|
|
5
|
+
"split_text",
|
|
6
|
+
"to_arabic_nums",
|
|
7
|
+
"to_english_nums",
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from ._random_string import random_string, random_string_urandom, random_hex_string
|
|
11
|
+
from ._chunked_text import split_text
|
|
12
|
+
from ._numerals import to_arabic_nums, to_english_nums
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
arabic_indic_digits = str.maketrans(
|
|
2
|
+
"0123456789", "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669"
|
|
3
|
+
)
|
|
4
|
+
english_digits = str.maketrans(
|
|
5
|
+
"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669", "0123456789"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def to_arabic_nums(string: str):
|
|
10
|
+
"""
|
|
11
|
+
Convert a string with english numerals to Arabic numerals
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
.. code-block:: python
|
|
15
|
+
>>> to_arabic_nums("1234")
|
|
16
|
+
'١٢٣٤'
|
|
17
|
+
|
|
18
|
+
Parameters:
|
|
19
|
+
string (``str`` || ``int``):
|
|
20
|
+
The string or integer containing English numerals to convert to Arabic numerals
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
``str``: The string with digits converted to Arabic numerals
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
return str(string).translate(arabic_indic_digits)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def to_english_nums(string: str):
|
|
30
|
+
"""
|
|
31
|
+
Convert a string with Arabic numerals to English numerals
|
|
32
|
+
|
|
33
|
+
Example:
|
|
34
|
+
.. code-block:: python
|
|
35
|
+
>>> to_english_nums("١٢٣٤")
|
|
36
|
+
'1234'
|
|
37
|
+
|
|
38
|
+
Parameters:
|
|
39
|
+
string (``str`` || ``int``):
|
|
40
|
+
The string or integer containing Arabic numerals to convert to English numerals
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
``str``: The string with Arabic numerals converted to English numerals
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
return str(string).translate(english_digits)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
__all__ = ("random_string", "random_string_urandom", "random_hex_string")
|
|
2
|
+
|
|
3
|
+
import binascii
|
|
4
|
+
import os
|
|
5
|
+
import string
|
|
6
|
+
import random
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
chars = list(string.digits + string.ascii_letters)
|
|
10
|
+
chars_len = len(chars)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def random_string(length: int):
|
|
14
|
+
r"""Generate a random string
|
|
15
|
+
|
|
16
|
+
Parameters:
|
|
17
|
+
length (``int``):
|
|
18
|
+
The length of the string
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
return "".join(random.choices(chars, k=length))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def random_string_urandom(length: int):
|
|
25
|
+
r"""Generate a random string using os.urandom
|
|
26
|
+
|
|
27
|
+
Parameters:
|
|
28
|
+
length (``int``):
|
|
29
|
+
The length of the string (in bytes)
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
return "".join(chars[b % chars_len] for b in os.urandom(length))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def random_hex_string(length):
|
|
36
|
+
r"""Generate a random hex string
|
|
37
|
+
|
|
38
|
+
Parameters:
|
|
39
|
+
length (``int``):
|
|
40
|
+
The length of the string (in bytes)
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
return binascii.hexlify(os.urandom(length)).decode()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
def as_tdlib_message_id(message_id: int) -> int:
|
|
2
|
-
"""
|
|
2
|
+
r"""
|
|
3
3
|
Convert server message ID to TDLib message ID
|
|
4
4
|
|
|
5
5
|
\Example:
|
|
@@ -20,7 +20,7 @@ def as_tdlib_message_id(message_id: int) -> int:
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def as_server_message_id(message_id: int) -> int:
|
|
23
|
-
"""
|
|
23
|
+
r"""
|
|
24
24
|
Converts TDLib message ID to server message ID
|
|
25
25
|
|
|
26
26
|
\Example:
|
|
@@ -43,7 +43,7 @@ def as_server_message_id(message_id: int) -> int:
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
def as_server_message_id_unchecked(message_id: int) -> int:
|
|
46
|
-
"""
|
|
46
|
+
r"""
|
|
47
47
|
Converts TDLib message ID to server message ID
|
|
48
48
|
|
|
49
49
|
\Example:
|
|
@@ -68,7 +68,7 @@ def as_server_message_id_unchecked(message_id: int) -> int:
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
def get_supergroup_chat_id(supergroup_id: int) -> int:
|
|
71
|
-
"""
|
|
71
|
+
r"""
|
|
72
72
|
Convert supergroup_id to chat_id
|
|
73
73
|
|
|
74
74
|
\Example:
|
|
@@ -87,12 +87,12 @@ def get_supergroup_chat_id(supergroup_id: int) -> int:
|
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
def get_supergroup_id(chat_id: int) -> int:
|
|
90
|
-
"""
|
|
90
|
+
r"""
|
|
91
91
|
Convert chat_id to supergroup_id
|
|
92
92
|
|
|
93
93
|
Example:
|
|
94
94
|
>>> get_supergroup_id(-1000123456789)
|
|
95
|
-
|
|
95
|
+
123456789
|
|
96
96
|
|
|
97
97
|
Parameters:
|
|
98
98
|
chat_id (``int``):
|
|
@@ -102,4 +102,4 @@ def get_supergroup_id(chat_id: int) -> int:
|
|
|
102
102
|
``int``: The supergroup ID
|
|
103
103
|
"""
|
|
104
104
|
|
|
105
|
-
return -
|
|
105
|
+
return -1000000000000 - chat_id
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
__all__ = ("random_string", "random_hex_string")
|
|
2
|
-
|
|
3
|
-
import binascii
|
|
4
|
-
import os
|
|
5
|
-
import string
|
|
6
|
-
import random
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
chars = string.ascii_letters + string.digits
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def random_string(length: int):
|
|
13
|
-
"""Generate a random string
|
|
14
|
-
|
|
15
|
-
Parameters:
|
|
16
|
-
length (``int``):
|
|
17
|
-
The length of the string
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
return "".join(random.choices(chars, k=length))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def random_hex_string(length):
|
|
24
|
-
"""Generate a random hex string
|
|
25
|
-
|
|
26
|
-
Parameters:
|
|
27
|
-
length (``int``):
|
|
28
|
-
The length of the string (in bytes)
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
return binascii.hexlify(os.urandom(length)).decode()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|