Skip to content

Commit cb4051b

Browse files
authored
Merge pull request #233 from davidhozic/develop
v2.3 prep
2 parents d061fe3 + 2ba17ae commit cb4051b

31 files changed

+1147
-433
lines changed

.github/workflows/python-tests.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run auto tests
1+
name: Self-Test
22

33
on:
44
push:
@@ -15,22 +15,33 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
python-version: ["3.8", "3.10"]
18-
1918
steps:
2019
- uses: actions/checkout@v3
2120
- name: Set up Python ${{ matrix.python-version }}
2221
uses: actions/setup-python@v3
2322
with:
2423
python-version: ${{ matrix.python-version }}
24+
- name: Disable initramfs update
25+
run: sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf
26+
- name: Disable man-db update
27+
run: sudo rm -f /var/lib/man-db/auto-update
2528
- name: Install dependencies
2629
run: |
2730
sudo apt update
2831
sudo apt install -y ffmpeg
2932
python -m pip install --upgrade pip
3033
python -m pip install .[all]
3134
python -m pip install .[testing]
32-
- name: Test with pytest
35+
- name: Test version compatibility
36+
env:
37+
DISCORD_TOKEN: ${{secrets.DATT}}
38+
if: ${{ matrix.python-version != 3.8 }}
39+
run: |
40+
pytest -v testing/test_period_dynamic.py
41+
- name: Test all
3342
env:
3443
DISCORD_TOKEN: ${{secrets.DATT}}
44+
if: ${{ matrix.python-version == 3.8 }}
3545
run: |
3646
pytest -v
47+

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
settings.json
33
dist/**
44
build**
5-
**.egg-info
5+
**.egg-info
6+
src/test.py
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from datetime import timedelta
2+
import daf
3+
import asyncio
4+
5+
6+
async def main():
7+
await daf.add_object(
8+
daf.GUILD(
9+
snowflake=123456789,
10+
messages=[
11+
daf.TextMESSAGE(
12+
None, timedelta(seconds=5), "Hello World",
13+
channels=daf.message.AutoCHANNEL("shill", exclude_pattern="shill-[7-9]")
14+
)
15+
],
16+
logging=True
17+
)
18+
)
19+
20+
21+
daf.run(
22+
token="SomeServerTokenHere",
23+
user_callback=main,
24+
)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from datetime import timedelta
2+
import daf
3+
4+
5+
# STATIC DEFINITION
6+
STATIC_AUTOGUILD_LIST = [
7+
daf.guild.AutoGUILD(
8+
include_pattern="NFT-Dragons", # Regex pattern of guild names that should be included
9+
exclude_pattern="NonFunctionalTesticle", # Regex pattern of guild names that should be excluded
10+
remove_after=None, # Never stop automatically managing guilds
11+
messages=[ # Pre-include messages
12+
daf.message.TextMESSAGE(None, timedelta(seconds=5), "Buy our NFT today!",daf.guild.AutoCHANNEL("shill", "promo", timedelta(seconds=60)))
13+
],
14+
logging=True, # The generated GUILD objects will have logging enabled
15+
interval=timedelta(hours=1) # Scan for new guilds in a period of one hour
16+
)
17+
]
18+
19+
20+
async def main():
21+
# DYNAMIC DEFINITION/ADDITION
22+
auto_guild = daf.guild.AutoGUILD(
23+
include_pattern="David", # Regex pattern of guild names that should be included
24+
exclude_pattern="NFT-Python", # Regex pattern of guild names that should be excluded
25+
remove_after=None, # Never stop automatically managing guilds
26+
messages=[], # Pre-include messages
27+
logging=True, # The generated GUILD objects will have logging enabled
28+
interval=timedelta(hours=1) # Scan for new guilds in a period of one hour
29+
)
30+
31+
await daf.add_object(auto_guild)
32+
await auto_guild.add_message(
33+
daf.message.TextMESSAGE(
34+
None, timedelta(seconds=5), "Buy our NFT today!",
35+
daf.guild.AutoCHANNEL("shill", "promo", timedelta(seconds=60)))
36+
)
37+
38+
39+
40+
daf.run(
41+
token="SomeServerTokenHere",
42+
user_callback=main,
43+
server_list=STATIC_AUTOGUILD_LIST
44+
)

docs/scripts/generate_autodoc.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
========================
3737
.. autoclass:: {object_path}
3838
:members:
39-
40-
{properties}
4139
"""
4240

4341
AUTO_ENUM_TEMPLATE =\
@@ -100,13 +98,7 @@
10098
if isinstance(item, EnumMeta):
10199
export_c_items += AUTO_ENUM_TEMPLATE.format(object_name=object_name, object_path=object_path) + "\n"
102100
else:
103-
properties = []
104-
for name in dir(item):
105-
attr = getattr(item, name)
106-
if isinstance(attr, property):
107-
properties.append(f".. autoproperty:: {object_path}.{name}")
108-
109-
export_c_items += AUTO_CLASS_TEMPLATE.format(object_name=object_name, object_path=object_path, properties="\n\n ".join(properties)) + "\n"
101+
export_c_items += AUTO_CLASS_TEMPLATE.format(object_name=object_name, object_path=object_path) + "\n"
110102

111103

112104
if export_f_items:

docs/source/changelog.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ Glossary
3232
Releases
3333
----------------------
3434

35+
v2.3
36+
=============
37+
- |BREAK_CH| Removed ``exceptions`` module, meaning that there are no DAFError derived exceptions from this version on.
38+
They are replaced with build-in Python exceptions.
39+
- Automatic scheme generation and management:
40+
41+
- :class:`daf.guild.AutoGUILD` class for auto-managed GUILD objects.
42+
- :class:`daf.message.AutoCHANNEL` class for auto-managed channels inside message.
43+
44+
- Debug levels:
45+
46+
- Added deprecated to :class:`~daf.logging.tracing.TraceLEVELS`.
47+
- Changed the :func:`daf.core.run`'s debug parameter to accept a value from :class:`~daf.logging.tracing.TraceLEVELS`, to dictate
48+
what level trace should be displayed.
49+
50+
- :ref:`Messages` objects period automatically increases if it is less than slow-mode timeout.
51+
- The :ref:`data_function`'s input function can now also be async.
52+
3553
v2.2
3654
===========
3755
- ``user_callback`` parameter for function :func:`daf.core.run` can now also be a regular function instead of just ``async``.

docs/source/classes.rst

Lines changed: 12 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
===============================
32
Classes
43
===============================
@@ -22,128 +21,61 @@ LoggerBASE
2221
.. autoclass:: daf.logging.LoggerBASE
2322
:members:
2423

25-
26-
2724

2825
LoggerCSV
2926
========================
3027
.. autoclass:: daf.logging.LoggerCSV
3128
:members:
3229

33-
34-
3530

3631
LoggerJSON
3732
========================
3833
.. autoclass:: daf.logging.LoggerJSON
3934
:members:
4035

41-
42-
4336

4437
LoggerSQL
4538
========================
4639
.. autoclass:: daf.logging.sql.LoggerSQL
4740
:members:
4841

49-
50-
5142

5243
----------------------------
53-
Exceptions
44+
Message data types
5445
----------------------------
5546

56-
DAFError
47+
EMBED
5748
========================
58-
.. autoclass:: daf.exceptions.DAFError
59-
:members:
60-
61-
49+
.. autoclass:: daf.dtypes.EMBED
6250

6351

64-
DAFNotFoundError
52+
FILE
6553
========================
66-
.. autoclass:: daf.exceptions.DAFNotFoundError
54+
.. autoclass:: daf.dtypes.FILE
6755
:members:
6856

69-
70-
7157

72-
DAFSQLError
58+
AUDIO
7359
========================
74-
.. autoclass:: daf.exceptions.DAFSQLError
60+
.. autoclass:: daf.dtypes.AUDIO
7561
:members:
7662

77-
78-
.. glossary::
79-
80-
DAF_SNOWFLAKE_NOT_FOUND:
81-
Value: 1
82-
83-
Info: Guild with specified snowflake was not found (or user).
84-
85-
DAF_USER_CREATE_DM:
86-
Value: 2
87-
88-
Info: Was unable to create DM with user (probably user not found).
89-
90-
DAF_YOUTUBE_STREAM_ERROR:
91-
Value: 3
92-
93-
Info: The given youtube link could not be streamed (AUDIO, VoiceMESSAGE).
94-
95-
DAF_FILE_NOT_FOUND:
96-
Value: 4
97-
98-
Info: The given file was not found.
99-
100-
DAF_SQL_CREATE_TABLES_ERROR:
101-
Value: 5
102-
103-
Info: Unable to create all the tables.
104-
105-
DAF_SQL_BEGIN_ENGINE_ERROR:
106-
Value: 7
107-
108-
Info: Unable to start engine.
109-
110-
DAF_SQL_CR_LT_VALUES_ERROR:
111-
Value: 8
112-
113-
Info: Unable to create lookuptables' rows.
114-
115-
DAF_SQL_SAVE_LOG_ERROR:
116-
Value: 12
117-
118-
Info: Unable to save the log to SQL
119-
12063

12164
----------------------------
122-
Message data types
65+
Automatic generation
12366
----------------------------
12467

125-
EMBED
68+
AutoCHANNEL
12669
========================
127-
.. autoclass:: daf.dtypes.EMBED
70+
.. autoclass:: daf.message.AutoCHANNEL
12871
:members:
129-
:exclude-members: Colour, Color
13072

13173

132-
FILE
74+
AutoGUILD
13375
========================
134-
.. autoclass:: daf.dtypes.FILE
76+
.. autoclass:: daf.guild.AutoGUILD
13577
:members:
13678

137-
138-
139-
140-
AUDIO
141-
========================
142-
.. autoclass:: daf.dtypes.AUDIO
143-
:members:
144-
145-
146-
14779

14880
----------------------------
14981
Messages
@@ -154,24 +86,18 @@ TextMESSAGE
15486
.. autoclass:: daf.message.TextMESSAGE
15587
:members:
15688

157-
.. autoproperty:: daf.message.TextMESSAGE.created_at
158-
15989

16090
DirectMESSAGE
16191
========================
16292
.. autoclass:: daf.message.DirectMESSAGE
16393
:members:
16494

165-
.. autoproperty:: daf.message.DirectMESSAGE.created_at
166-
16795

16896
VoiceMESSAGE
16997
========================
17098
.. autoclass:: daf.message.VoiceMESSAGE
17199
:members:
172100

173-
.. autoproperty:: daf.message.VoiceMESSAGE.created_at
174-
175101

176102
----------------------------
177103
Guilds
@@ -182,21 +108,9 @@ GUILD
182108
.. autoclass:: daf.guild.GUILD
183109
:members:
184110

185-
.. autoproperty:: daf.guild.GUILD.created_at
186-
187-
.. autoproperty:: daf.guild.GUILD.messages
188-
189-
.. autoproperty:: daf.guild.GUILD.snowflake
190-
191111

192112
USER
193113
========================
194114
.. autoclass:: daf.guild.USER
195115
:members:
196116

197-
.. autoproperty:: daf.guild.USER.created_at
198-
199-
.. autoproperty:: daf.guild.USER.messages
200-
201-
.. autoproperty:: daf.guild.USER.snowflake
202-

docs/source/conf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
elif readthedocs_release is not None:
2929
version = readthedocs_release
3030
else:
31-
with open("../../version.txt", "r", encoding="utf-8") as rf:
32-
version = rf.read().strip()
31+
version = "v0.0.1"
3332

3433

3534
# -- General configuration ---------------------------------------------------
@@ -71,12 +70,16 @@
7170
autodoc_typehints_format = "short"
7271

7372

73+
developement_build = os.environ.get("DOC_DEVELOPMENT", default="False")
74+
developement_build = True if developement_build == "True" else False
75+
7476
autodoc_default_options = {
75-
'members': True,
7677
'member-order': 'bysource',
78+
"private-members": developement_build
7779
}
7880

7981

82+
8083
# Intersphinx
8184
intersphinx_mapping = {
8285
'PyCord': ("https://docs.pycord.dev/en/stable/", None)

0 commit comments

Comments
 (0)