Jedutils 0.2.3__tar.gz → 0.2.5__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.
Files changed (33) hide show
  1. {Jedutils-0.2.3 → Jedutils-0.2.5}/Jedutils.egg-info/PKG-INFO +1 -1
  2. {Jedutils-0.2.3 → Jedutils-0.2.5}/Jedutils.egg-info/SOURCES.txt +3 -1
  3. {Jedutils-0.2.3 → Jedutils-0.2.5}/PKG-INFO +1 -1
  4. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/__init__.py +1 -1
  5. Jedutils-0.2.5/jedutils/base62/__init__.py +3 -0
  6. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/base62/b62.py +2 -2
  7. Jedutils-0.2.5/jedutils/strings/__init__.py +12 -0
  8. Jedutils-0.2.5/jedutils/strings/_random_string.py +43 -0
  9. Jedutils-0.2.5/jedutils/tdlib/__init__.py +15 -0
  10. Jedutils-0.2.5/jedutils/tdlib/arithmetic.py +105 -0
  11. Jedutils-0.2.3/jedutils/base62/__init__.py +0 -1
  12. Jedutils-0.2.3/jedutils/strings/__init__.py +0 -4
  13. Jedutils-0.2.3/jedutils/strings/_random_string.py +0 -31
  14. {Jedutils-0.2.3 → Jedutils-0.2.5}/Jedutils.egg-info/dependency_links.txt +0 -0
  15. {Jedutils-0.2.3 → Jedutils-0.2.5}/Jedutils.egg-info/requires.txt +0 -0
  16. {Jedutils-0.2.3 → Jedutils-0.2.5}/Jedutils.egg-info/top_level.txt +0 -0
  17. {Jedutils-0.2.3 → Jedutils-0.2.5}/LICENSE +0 -0
  18. {Jedutils-0.2.3 → Jedutils-0.2.5}/MANIFEST.in +0 -0
  19. {Jedutils-0.2.3 → Jedutils-0.2.5}/README.md +0 -0
  20. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/asyncio/__init__.py +0 -0
  21. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/asyncio/_async_redis_pipe.py +0 -0
  22. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/asyncio/_concurrency_manager.py +0 -0
  23. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/asyncio/_run_async.py +0 -0
  24. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/asyncio/_rwlock.py +0 -0
  25. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/asyncio/network/__init__.py +0 -0
  26. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/asyncio/network/_dl.py +0 -0
  27. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/databases/__init__.py +0 -0
  28. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/databases/_in_memory.py +0 -0
  29. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/math/__init__.py +0 -0
  30. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/math/_number_formatter.py +0 -0
  31. {Jedutils-0.2.3 → Jedutils-0.2.5}/jedutils/strings/_chunked_text.py +0 -0
  32. {Jedutils-0.2.3 → Jedutils-0.2.5}/setup.cfg +0 -0
  33. {Jedutils-0.2.3 → Jedutils-0.2.5}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Jedutils
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: Jedutils is a Python utilities package that provides a collection of useful helper functions.
5
5
  Home-page: https://github.com/AYMENJD/jedutils
6
6
  Author: AYMEN Mohammed
@@ -23,4 +23,6 @@ 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/_random_string.py
26
+ jedutils/strings/_random_string.py
27
+ jedutils/tdlib/__init__.py
28
+ jedutils/tdlib/arithmetic.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Jedutils
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: Jedutils is a Python utilities package that provides a collection of useful helper functions.
5
5
  Home-page: https://github.com/AYMENJD/jedutils
6
6
  Author: AYMEN Mohammed
@@ -1,3 +1,3 @@
1
- __version__ = "0.2.3"
1
+ __version__ = "0.2.5"
2
2
  __copyright__ = "Copyright (c) 2023-2024 AYMEN Mohammed ~ https://github.com/AYMENJD"
3
3
  __license__ = "MIT License"
@@ -0,0 +1,3 @@
1
+ from .b62 import BASE62_CHARS, b62encode, b62decode
2
+
3
+ __all__ = ["BASE62_CHARS", "b62encode", "b62decode"]
@@ -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,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()
@@ -0,0 +1,15 @@
1
+ from .arithmetic import (
2
+ as_tdlib_message_id,
3
+ as_server_message_id,
4
+ as_server_message_id_unchecked,
5
+ get_supergroup_chat_id,
6
+ get_supergroup_id,
7
+ )
8
+
9
+ __all__ = (
10
+ "as_tdlib_message_id",
11
+ "as_server_message_id",
12
+ "as_server_message_id_unchecked",
13
+ "get_supergroup_chat_id",
14
+ "get_supergroup_id",
15
+ )
@@ -0,0 +1,105 @@
1
+ def as_tdlib_message_id(message_id: int) -> int:
2
+ r"""
3
+ Convert server message ID to TDLib message ID
4
+
5
+ \Example:
6
+ .. code-block:: python
7
+
8
+ >>> as_tdlib_message_id(12345)
9
+ 12944670720
10
+
11
+ \Parameters:
12
+ message_id (``int``):
13
+ Server message ID
14
+
15
+ \Returns:
16
+ ``int``: TDLib message ID
17
+ """
18
+
19
+ return message_id << 20
20
+
21
+
22
+ def as_server_message_id(message_id: int) -> int:
23
+ r"""
24
+ Converts TDLib message ID to server message ID
25
+
26
+ \Example:
27
+ .. code-block:: python
28
+
29
+ >>> as_server_message_id(12944670720)
30
+ 12345
31
+
32
+ \Parameters:
33
+ message_id (``int``):
34
+ TDLib message ID
35
+
36
+ \Returns:
37
+ ``int``: The server message ID
38
+ """
39
+
40
+ result = message_id >> 20
41
+ assert as_tdlib_message_id(result) == message_id
42
+ return result
43
+
44
+
45
+ def as_server_message_id_unchecked(message_id: int) -> int:
46
+ r"""
47
+ Converts TDLib message ID to server message ID
48
+
49
+ \Example:
50
+ >>> as_server_message_id_unchecked(12944670720)
51
+ 12345
52
+ >>> as_server_message_id_unchecked(12944670721) # Invalid ID
53
+ 0
54
+
55
+ \Parameters:
56
+ message_id (``int``):
57
+ TDLib message ID
58
+
59
+ \Returns:
60
+ ``int``:
61
+ The server message ID or 0 if the conversion is invalid
62
+ """
63
+
64
+ result = message_id >> 20
65
+ if as_tdlib_message_id(result) != message_id:
66
+ return 0
67
+ return result
68
+
69
+
70
+ def get_supergroup_chat_id(supergroup_id: int) -> int:
71
+ r"""
72
+ Convert supergroup_id to chat_id
73
+
74
+ \Example:
75
+ >>> get_supergroup_chat_id(-123456789)
76
+ -1000123456789
77
+
78
+ \Parameters:
79
+ supergroup_id (``int``):
80
+ ID of the supergroup
81
+
82
+ \Returns:
83
+ ``int``: The chat ID of the supergroup
84
+ """
85
+
86
+ return -1000000000000 - (supergroup_id if supergroup_id > 0 else -supergroup_id)
87
+
88
+
89
+ def get_supergroup_id(chat_id: int) -> int:
90
+ r"""
91
+ Convert chat_id to supergroup_id
92
+
93
+ Example:
94
+ >>> get_supergroup_id(-1000123456789)
95
+ 123456789
96
+
97
+ Parameters:
98
+ chat_id (``int``):
99
+ The chat ID to convert to a supergroup ID
100
+
101
+ Returns:
102
+ ``int``: The supergroup ID
103
+ """
104
+
105
+ return -1000000000000 - chat_id
@@ -1 +0,0 @@
1
- from .b62 import BASE62_CHARS, b62encode, b62decode
@@ -1,4 +0,0 @@
1
- __all__ = ("random_string", "random_hex_string", "split_text")
2
-
3
- from ._random_string import random_string, random_hex_string
4
- from ._chunked_text import split_text
@@ -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