crxsnake 0.0.0__py3-none-any.whl → 1.3.2__py3-none-any.whl
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.
- crxsnake/__init__.py +9 -9
- crxsnake/cogs.py +4 -3
- crxsnake/files.py +7 -7
- crxsnake/issues/crx.py +3 -2
- crxsnake/issues/hotline.py +8 -6
- crxsnake/tortoise.py +3 -8
- crxsnake-1.3.2.dist-info/METADATA +29 -0
- crxsnake-1.3.2.dist-info/RECORD +14 -0
- crxsnake-0.0.0.dist-info/METADATA +0 -5
- crxsnake-0.0.0.dist-info/RECORD +0 -14
- {crxsnake-0.0.0.dist-info → crxsnake-1.3.2.dist-info}/LICENSE +0 -0
- {crxsnake-0.0.0.dist-info → crxsnake-1.3.2.dist-info}/WHEEL +0 -0
- {crxsnake-0.0.0.dist-info → crxsnake-1.3.2.dist-info}/top_level.txt +0 -0
crxsnake/__init__.py
CHANGED
@@ -4,16 +4,16 @@ from .files import read_json, write_json
|
|
4
4
|
from .tortoise import Database
|
5
5
|
from .misc import *
|
6
6
|
|
7
|
-
from
|
8
|
-
from
|
7
|
+
from .issues.hotline import IssueHotline
|
8
|
+
from .issues.crx import IssueCRX
|
9
9
|
|
10
10
|
|
11
11
|
__all__ = [
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
"logger",
|
13
|
+
"load_cogs",
|
14
|
+
"read_json",
|
15
|
+
"write_json",
|
16
|
+
"Database",
|
17
|
+
"IssueHotline",
|
18
|
+
"IssueCRX",
|
19
19
|
]
|
crxsnake/cogs.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
from loguru import logger
|
2
|
+
|
1
3
|
from sys import path
|
2
4
|
from pathlib import Path
|
3
|
-
from rich.console import Console
|
4
5
|
|
5
6
|
|
6
|
-
async def load_cogs(bot, directory="src"):
|
7
|
+
async def load_cogs(bot, directory="src") -> None:
|
7
8
|
directory_path = Path(directory)
|
8
9
|
path.append(str(directory_path))
|
9
10
|
|
@@ -13,4 +14,4 @@ async def load_cogs(bot, directory="src"):
|
|
13
14
|
try:
|
14
15
|
bot.load_extension(f"{entry.name}.{filename.stem}")
|
15
16
|
except Exception:
|
16
|
-
|
17
|
+
logger.exception(f"An error occurred while loading cog {entry.name}.{filename.stem}")
|
crxsnake/files.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
from loguru import logger
|
2
|
+
from aiofiles import open
|
3
|
+
|
1
4
|
from typing import Optional, Any
|
2
5
|
from json import loads, dumps
|
3
6
|
|
4
|
-
from aiofiles import open
|
5
|
-
from rich.console import Console
|
6
|
-
|
7
7
|
|
8
8
|
async def read_json(path: str, *keys: str) -> Optional[Any]:
|
9
9
|
"""
|
@@ -22,16 +22,16 @@ async def read_json(path: str, *keys: str) -> Optional[Any]:
|
|
22
22
|
return file_data
|
23
23
|
|
24
24
|
except Exception:
|
25
|
-
|
25
|
+
logger.exception("An error occurred while reading json file")
|
26
26
|
|
27
27
|
|
28
|
-
async def write_json(path: str, data: Any) ->
|
28
|
+
async def write_json(path: str, data: Any) -> bool:
|
29
29
|
"""
|
30
30
|
Write data to json file.
|
31
31
|
"""
|
32
32
|
try:
|
33
33
|
async with open(path, "w", encoding="utf-8") as file:
|
34
34
|
await file.write(dumps(data, ensure_ascii=False, indent=2))
|
35
|
-
|
35
|
+
return True
|
36
36
|
except Exception:
|
37
|
-
|
37
|
+
logger.exception("An error occurred while writing json file")
|
crxsnake/issues/crx.py
CHANGED
@@ -3,12 +3,13 @@ from typing import List, Dict, Any
|
|
3
3
|
|
4
4
|
class IssueCRX:
|
5
5
|
async def create_items(
|
6
|
-
self,
|
6
|
+
self,
|
7
|
+
issue_type: str,
|
8
|
+
items_list: List[Dict[str, Any]]
|
7
9
|
) -> Dict[str, List[Dict[str, Any]]]:
|
8
10
|
"""
|
9
11
|
Create a dictionary with generated codes and processed items.
|
10
12
|
"""
|
11
|
-
|
12
13
|
issue_dict = {"items": [], "cars": [], "sets": []}
|
13
14
|
issue_dict[issue_type].extend(items_list)
|
14
15
|
return issue_dict
|
crxsnake/issues/hotline.py
CHANGED
@@ -13,13 +13,13 @@ class IssueHotline:
|
|
13
13
|
return f"{part1}-{part2}-{part3}"
|
14
14
|
|
15
15
|
async def __generate_count(
|
16
|
-
self,
|
16
|
+
self,
|
17
|
+
items_list: List[Dict[str, Any]]
|
17
18
|
) -> AsyncGenerator[Dict[str, Any], None]:
|
18
19
|
"""
|
19
20
|
Generate item counts based on the MAX_STACK value.
|
20
21
|
Splits items into full stacks and the remainder.
|
21
22
|
"""
|
22
|
-
|
23
23
|
for item in items_list:
|
24
24
|
item_count = item.get("m_count", 0)
|
25
25
|
item_name = item.get("m_item", "")
|
@@ -32,12 +32,13 @@ class IssueHotline:
|
|
32
32
|
yield {"m_item": item_name, "m_count": remainder}
|
33
33
|
|
34
34
|
async def create_items(
|
35
|
-
self,
|
35
|
+
self,
|
36
|
+
issue_name: str,
|
37
|
+
items_list: List[Dict[str, Any]]
|
36
38
|
) -> Dict[str, Any]:
|
37
39
|
"""
|
38
40
|
Create a dictionary with generated codes and processed items.
|
39
41
|
"""
|
40
|
-
|
41
42
|
processed_items = [item async for item in self.__generate_count(items_list)]
|
42
43
|
return {
|
43
44
|
"m_CodeArray": [
|
@@ -55,12 +56,13 @@ class IssueHotline:
|
|
55
56
|
}
|
56
57
|
|
57
58
|
async def create_vehicle(
|
58
|
-
self,
|
59
|
+
self,
|
60
|
+
issue_name: str,
|
61
|
+
items_dict: Dict[str, Any]
|
59
62
|
) -> Dict[str, Any]:
|
60
63
|
"""
|
61
64
|
Create a dictionary with generated code and vehicle data.
|
62
65
|
"""
|
63
|
-
|
64
66
|
return {
|
65
67
|
"m_CodeArray": [
|
66
68
|
{
|
crxsnake/tortoise.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
+
from loguru import logger
|
1
2
|
from tortoise import Tortoise
|
2
|
-
from rich.console import Console
|
3
3
|
|
4
4
|
|
5
5
|
class Database:
|
@@ -13,16 +13,11 @@ class Database:
|
|
13
13
|
try:
|
14
14
|
await Tortoise.init(db_url=self.DB_URL, modules=self.DB_MODEL)
|
15
15
|
await Tortoise.generate_schemas()
|
16
|
-
|
17
16
|
except Exception:
|
18
|
-
|
17
|
+
logger.exception("An error occurred while connecting to the database")
|
19
18
|
|
20
19
|
async def db_disconnect(self) -> None:
|
21
20
|
"""
|
22
21
|
Disconnect from the database.
|
23
22
|
"""
|
24
|
-
|
25
|
-
await Tortoise.close_connections()
|
26
|
-
|
27
|
-
except Exception:
|
28
|
-
Console().print_exception(show_locals=True)
|
23
|
+
await Tortoise.close_connections()
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: crxsnake
|
3
|
+
Version: 1.3.2
|
4
|
+
Home-page: https://discord.gg/EEp67FWQDP
|
5
|
+
Author: CRX-DEV
|
6
|
+
Author-email: cherniq66@gmail.com
|
7
|
+
License: MIT License
|
8
|
+
Project-URL: Repository, https://github.com/CRX-DEV/crxsnake
|
9
|
+
Project-URL: Discord, https://discord.gg/EEp67FWQDP
|
10
|
+
Description-Content-Type: text/markdown
|
11
|
+
License-File: LICENSE
|
12
|
+
Requires-Dist: setuptools==72.2.0
|
13
|
+
Requires-Dist: tortoise-orm==0.21.0
|
14
|
+
Requires-Dist: disnake==2.9.2
|
15
|
+
Requires-Dist: aiofiles==23.2.1
|
16
|
+
Requires-Dist: loguru==0.7.2
|
17
|
+
|
18
|
+
# CRX-Snake
|
19
|
+
|
20
|
+
**CRX-Snake** is a set of utilities designed to simplify the development of projects, including the creation of Discord bots. This library contains a number of features and tools to help you quickly develop and customize bots and other components of your projects.
|
21
|
+
|
22
|
+
## Description
|
23
|
+
|
24
|
+
CRX-Snake was developed specifically for internal use and is now available to other developers. It provides user-friendly features and solutions for common tasks in bot development and project management. It includes:
|
25
|
+
|
26
|
+
- **Features for working with Discord**: Tools for creating and managing Discord bots using the Disnake library.
|
27
|
+
- **File Utilities**: Functions for reading and writing JSON files, making it easy to work with configurations and data.
|
28
|
+
- **Database Tools**: Interfaces with Tortoise ORM for data management and query execution.
|
29
|
+
- **Logging and debugging**: Includes functions for error logging and debugging.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
crxsnake/__init__.py,sha256=Va8nawElNujlj6tmw30e3X723hkBbOcX0eP96D_F9iM,375
|
2
|
+
crxsnake/cogs.py,sha256=yllAQ7WEES0mrIrVacAjtW103XL-Z-kdC1wWKliKTTU,602
|
3
|
+
crxsnake/files.py,sha256=nNFUcyYefu-DrLiT2HkWoDpMjZ9mSxLxPp0tmtSlOLg,1049
|
4
|
+
crxsnake/logger.py,sha256=-TXqHfagCV-TrnwJrucKEa61BRePW34sep0K9RCbHn8,764
|
5
|
+
crxsnake/misc.py,sha256=VAv6FTQ-Ekwudtm8iLKjSu3WFSJuTw8Nrs_Gclo1W_c,402
|
6
|
+
crxsnake/tortoise.py,sha256=lQQzxrdXw_4reKtLVUzlD8UL3BYehUSWaeEQXd8eJ-c,682
|
7
|
+
crxsnake/issues/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
crxsnake/issues/crx.py,sha256=Ka6V7q4ISJdoH2tI_avYzT67rGWcaKFTHIX4p6V5biI,447
|
9
|
+
crxsnake/issues/hotline.py,sha256=08z38-7TCp2p086Ga_mMSY7lzH3MxdwB4mZgt4J9Nls,2722
|
10
|
+
crxsnake-1.3.2.dist-info/LICENSE,sha256=xt4Ru6tOCU8e2wVlx_lgx7wh-sNLKbiCbmANzr2e3cc,1085
|
11
|
+
crxsnake-1.3.2.dist-info/METADATA,sha256=4yP4nBY50t5myXXNEduKPGTmmIdLYyyo0_M7eFefdgE,1451
|
12
|
+
crxsnake-1.3.2.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
13
|
+
crxsnake-1.3.2.dist-info/top_level.txt,sha256=GOgG6tMH05czsfM6y-Tvm9LUSd-0PPuuuYkkkbWHZjQ,9
|
14
|
+
crxsnake-1.3.2.dist-info/RECORD,,
|
crxsnake-0.0.0.dist-info/RECORD
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
crxsnake/__init__.py,sha256=F8W6qG38P8nF8nfCCPfEdPpzJdFX2VyQdzVUvAsPXaM,365
|
2
|
-
crxsnake/cogs.py,sha256=gXC81xWcpUZ-YOpI8BqiUoy7s8AInLr0M1asrSFAxEg,557
|
3
|
-
crxsnake/files.py,sha256=M6uCktEFaDUuVH3CHUcr9bITZa_ruEsAjIRqf_5gM3o,997
|
4
|
-
crxsnake/logger.py,sha256=-TXqHfagCV-TrnwJrucKEa61BRePW34sep0K9RCbHn8,764
|
5
|
-
crxsnake/misc.py,sha256=VAv6FTQ-Ekwudtm8iLKjSu3WFSJuTw8Nrs_Gclo1W_c,402
|
6
|
-
crxsnake/tortoise.py,sha256=R0IwdfvsS5FGUXlGVIdI1I48_Xde_qz_Rd8E2e_NNHY,768
|
7
|
-
crxsnake/issues/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
crxsnake/issues/crx.py,sha256=mhYX4iWmyPw5rV60rb0m18HAy7s72aTFwA-MIsdXV1E,431
|
9
|
-
crxsnake/issues/hotline.py,sha256=tLUVp59O8YesXxlmVxOeLcIjDN7RiwWTZGCVKIxXR-Q,2683
|
10
|
-
crxsnake-0.0.0.dist-info/LICENSE,sha256=xt4Ru6tOCU8e2wVlx_lgx7wh-sNLKbiCbmANzr2e3cc,1085
|
11
|
-
crxsnake-0.0.0.dist-info/METADATA,sha256=dyV-kv1iq56dUJAdhzbldudAZP3ajj8n9IIte7eHKf4,80
|
12
|
-
crxsnake-0.0.0.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
13
|
-
crxsnake-0.0.0.dist-info/top_level.txt,sha256=GOgG6tMH05czsfM6y-Tvm9LUSd-0PPuuuYkkkbWHZjQ,9
|
14
|
-
crxsnake-0.0.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|