-
Notifications
You must be signed in to change notification settings - Fork 6
/
scripts.py
70 lines (49 loc) · 1.91 KB
/
scripts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# This file is used for calling scripts through the poetry CLI.
from subprocess import CalledProcessError, run
libraries = [
'discord-py',
'discord.py-message-components',
'disnake',
'nextcord',
'py-cord',
]
def is_installed(library: str) -> bool:
"""Checks to see if a library is installed."""
try:
run(['poetry', 'show', library, '--quiet'], check=True)
except CalledProcessError:
return False
else:
return True
def reset_environment(library: str):
"""Removes all libraries from the poetry environment."""
print('Resetting test environment...')
for installed_library in libraries:
if library == installed_library:
continue
run(['poetry', 'remove', installed_library, '--quiet'])
if not is_installed(library):
run(['poetry', 'add', library, '--dev', '--quiet'])
def fmt():
"""Runs black on the project source directory. Uses the config defined in `pyproject.toml`."""
run(['black', 'cogwatch/', 'integrations/', 'examples', 'tests', './'])
def discord4py():
"""Runs the discord.py-message-components integration test."""
reset_environment('discord.py-message-components')
run(['poetry', 'run', 'python', 'integrations/discord4py/main.py'])
def discordpy():
"""Runs the discord.py integration test."""
reset_environment('discord-py')
run(['poetry', 'run', 'python', 'integrations/discord-py/main.py'])
def disnake():
"""Runs the disnake integration test."""
reset_environment('disnake')
run(['poetry', 'run', 'python', 'integrations/disnake/main.py'])
def nextcord():
"""Runs the nextcord integration test."""
reset_environment('nextcord')
run(['poetry', 'run', 'python', 'integrations/nextcord/main.py'])
def pycord():
"""Runs the py-cord integration test."""
reset_environment('py-cord')
run(['poetry', 'run', 'python', 'integrations/py-cord/main.py'])