sillydev 0.1.0__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.
@@ -0,0 +1,8 @@
1
+ node_modules/
2
+ dist/
3
+ .venv
4
+ venv/
5
+ __pycache__/
6
+ *.egg-info
7
+ .pytest_cache/
8
+ *.tsbuildinfo
sillydev-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Silly Development
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,248 @@
1
+ Metadata-Version: 2.5
2
+ Name: sillydev
3
+ Version: 0.1.0
4
+ Summary: Python client, CLI and MCP server for the Silly Development panel API.
5
+ Project-URL: Homepage, https://sillydev.co.uk
6
+ Project-URL: Documentation, https://sillydev.co.uk/docs/panel
7
+ Project-URL: Source, https://github.com/TheGamer3514/silly-development/tree/main/sdk/python
8
+ Author: Silly Development
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: api,bot hosting,mcp,sdk,silly development,sillydev
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.9
25
+ Requires-Dist: httpx<1,>=0.23
26
+ Provides-Extra: dev
27
+ Requires-Dist: mcp>=1.2; (python_version >= '3.10') and extra == 'dev'
28
+ Requires-Dist: pytest>=7; extra == 'dev'
29
+ Requires-Dist: respx>=0.20; extra == 'dev'
30
+ Provides-Extra: mcp
31
+ Requires-Dist: mcp>=1.2; (python_version >= '3.10') and extra == 'mcp'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # sillydev
35
+
36
+ The Python client for the [Silly Development](https://sillydev.co.uk) panel API: start, stop and
37
+ restart your bots, send console commands, manage files and backups, and deploy from Git, all from
38
+ your own code. It also comes with a `sillydev` command line tool and an MCP server for AI assistants.
39
+
40
+ Full API docs: <https://sillydev.co.uk/docs/panel>
41
+
42
+ ## Install
43
+
44
+ ```sh
45
+ pip install sillydev
46
+ ```
47
+
48
+ Python 3.9 or later. The only dependency is [httpx](https://www.python-httpx.org/).
49
+
50
+ ## Quick start
51
+
52
+ Create an API key in the panel under **Account, API keys** and put it in the `SILLYDEV_API_KEY`
53
+ environment variable. Keys start with `sdevc_` (older `ptlc_` keys keep working).
54
+
55
+ ```python
56
+ from sillydev import SillyDev
57
+
58
+ client = SillyDev() # or SillyDev(api_key="sdevc_...")
59
+
60
+ for server in client.panel.servers.list():
61
+ print(server["identifier"], server["name"])
62
+
63
+ client.panel.servers.power("1a7ce997", "restart")
64
+ client.panel.servers.command("1a7ce997", "say Back in a minute")
65
+ ```
66
+
67
+ Each server has an 8-character identifier, shown in the panel and in the `identifier` field of
68
+ every server. Every method takes it (or the full UUID) as its first argument.
69
+
70
+ ## Examples
71
+
72
+ ```python
73
+ from sillydev import SillyDev
74
+
75
+ client = SillyDev()
76
+ panel = client.panel
77
+ server = "1a7ce997"
78
+
79
+ # Live state and resource use
80
+ stats = panel.servers.resources(server)
81
+ print(stats["current_state"], stats["resources"]["memory_bytes"])
82
+
83
+ # Files
84
+ for f in panel.files.list(server, directory="/"):
85
+ print(f["name"], f["size"])
86
+ config = panel.files.read(server, "/config.json")
87
+ panel.files.write(server, "/config.json", config.replace("debug", "info"))
88
+
89
+ # Backups
90
+ backup = panel.backups.create(server, name="before-update")
91
+ print(backup["uuid"])
92
+
93
+ # Deploy the linked Git repository
94
+ deployment = panel.git.deploy(server)
95
+ print(deployment["status"]) # "queued"
96
+
97
+ # Startup variables
98
+ panel.startup.set_variable(server, "MAIN_FILE", "bot.py")
99
+ ```
100
+
101
+ ### Responses
102
+
103
+ Methods return plain dicts and lists. The API's `{"object": ..., "attributes": {...}}` envelopes
104
+ are removed, so `panel.servers.get(server)["name"]` just works.
105
+
106
+ ### Pagination
107
+
108
+ `panel.servers.list()`, `panel.backups.list()`, `panel.servers.activity()` and
109
+ `panel.account.activity()` return iterators that fetch the next page as you go. For one page at a
110
+ time, with the list's `meta`, use the `*_page` methods:
111
+
112
+ ```python
113
+ page = panel.servers.list_page(page=1, per_page=25)
114
+ print(page.total, page.has_next, page.meta.get("pending_orders"))
115
+ ```
116
+
117
+ ### Async
118
+
119
+ ```python
120
+ import asyncio
121
+ from sillydev import AsyncSillyDev
122
+
123
+ async def main():
124
+ async with AsyncSillyDev() as client:
125
+ async for server in client.panel.servers.list():
126
+ print(server["name"])
127
+ await client.panel.servers.restart("1a7ce997")
128
+
129
+ asyncio.run(main())
130
+ ```
131
+
132
+ ### Errors
133
+
134
+ Every error is a `sillydev.SillyDevError`. Errors the API answers with have their own class:
135
+
136
+ | Status | Exception |
137
+ | --- | --- |
138
+ | 400 | `BadRequestError` |
139
+ | 401 | `AuthenticationError` |
140
+ | 403 | `PermissionDeniedError` |
141
+ | 404 | `NotFoundError` |
142
+ | 409 | `ConflictError` |
143
+ | 422 | `ValidationError` (`.errors` has every problem, `.fields` groups them by field) |
144
+ | 429 | `RateLimitError` (`.retry_after` in seconds) |
145
+ | 5xx | `ServerError` |
146
+
147
+ If the API cannot be reached at all you get `APIConnectionError`.
148
+
149
+ ```python
150
+ from sillydev import ConflictError, NotFoundError
151
+
152
+ try:
153
+ panel.servers.restart(server)
154
+ except ConflictError:
155
+ print("The server is installing or being transferred; try again later")
156
+ except NotFoundError:
157
+ print("No such server, or the key cannot reach it")
158
+ ```
159
+
160
+ ### Retries and limits
161
+
162
+ Each account may make 768 requests a minute. Requests answered 429 are retried
163
+ twice by default, and reads answered 502, 503 or 504 too (a command or power action is not
164
+ repeated, since the server may already have run it), waiting as long as the `Retry-After` header asks. Change it with
165
+ `SillyDev(max_retries=...)`; `0` turns retries off.
166
+
167
+ Ordering a paid server (`panel.billing.checkout(...)`) always sends an `Idempotency-Key`, so a
168
+ retried request never buys twice. Pass `idempotency_key=` yourself to make retries safe across runs.
169
+
170
+ ### Everything else
171
+
172
+ `client.panel` has one attribute for each area of the API:
173
+
174
+ | Attribute | What it covers |
175
+ | --- | --- |
176
+ | `servers` | list, get, delete, resources, activity, permissions, power, command, share logs, websocket |
177
+ | `settings` | rename, reinstall, Docker image, status badge |
178
+ | `startup` | startup command and variables |
179
+ | `files` | list, read, write, rename, copy, compress, decompress, delete, folders, chmod, pull, signed URLs |
180
+ | `backups` | list, create, get, delete, download, lock, restore |
181
+ | `schedules` | schedules and their tasks |
182
+ | `network` | allocations (ports) |
183
+ | `subusers` | other accounts with access to a server |
184
+ | `git` | link a repository, deploy, deployments, `sillydev.conf` |
185
+ | `account` | the key's account and its activity |
186
+ | `server_creation` | create free servers |
187
+ | `databases` | free MariaDB and Postgres databases |
188
+ | `billing` | paid servers and subscriptions |
189
+
190
+ Every method's docstring names the API operation it calls, so you can look it up in the
191
+ [API reference](https://sillydev.co.uk/docs/panel).
192
+
193
+ ## Command line
194
+
195
+ ```sh
196
+ export SILLYDEV_API_KEY="sdevc_..."
197
+
198
+ sillydev servers list
199
+ sillydev status 1a7ce997
200
+ sillydev power 1a7ce997 restart
201
+ sillydev command 1a7ce997 "say hi"
202
+ sillydev deploy 1a7ce997
203
+ sillydev files ls 1a7ce997 /src
204
+ sillydev files cat 1a7ce997 /config.json
205
+ sillydev backups list 1a7ce997
206
+ sillydev backups create 1a7ce997 --name before-update
207
+ ```
208
+
209
+ Add `--json` to any command for JSON output. `python -m sillydev` works too.
210
+
211
+ ## MCP server
212
+
213
+ The MCP server lets an AI assistant (Claude Desktop, Claude Code, Cursor and others) check on and
214
+ control your servers. It needs Python 3.10 or later:
215
+
216
+ ```sh
217
+ pip install 'sillydev[mcp]'
218
+ ```
219
+
220
+ Then add it to your assistant's MCP settings, for example:
221
+
222
+ ```json
223
+ {
224
+ "mcpServers": {
225
+ "sillydev": {
226
+ "command": "sillydev-mcp",
227
+ "env": { "SILLYDEV_API_KEY": "sdevc_..." }
228
+ }
229
+ }
230
+ }
231
+ ```
232
+
233
+ Its tools are: list servers, server status, power action, send command, list files, read file,
234
+ Git deploy and list backups. There is nothing for billing or for deleting anything. Give it a key
235
+ limited to the servers and permissions you want the assistant to have.
236
+
237
+ ## Configuration
238
+
239
+ | Option | Environment variable | Default |
240
+ | --- | --- | --- |
241
+ | `api_key` | `SILLYDEV_API_KEY` | (required) |
242
+ | `base_url` | `SILLYDEV_BASE_URL` | `https://sillydev.co.uk/panel/api/client` |
243
+ | `timeout` | | 60 seconds |
244
+ | `max_retries` | | 2 |
245
+
246
+ ## License
247
+
248
+ MIT
@@ -0,0 +1,215 @@
1
+ # sillydev
2
+
3
+ The Python client for the [Silly Development](https://sillydev.co.uk) panel API: start, stop and
4
+ restart your bots, send console commands, manage files and backups, and deploy from Git, all from
5
+ your own code. It also comes with a `sillydev` command line tool and an MCP server for AI assistants.
6
+
7
+ Full API docs: <https://sillydev.co.uk/docs/panel>
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ pip install sillydev
13
+ ```
14
+
15
+ Python 3.9 or later. The only dependency is [httpx](https://www.python-httpx.org/).
16
+
17
+ ## Quick start
18
+
19
+ Create an API key in the panel under **Account, API keys** and put it in the `SILLYDEV_API_KEY`
20
+ environment variable. Keys start with `sdevc_` (older `ptlc_` keys keep working).
21
+
22
+ ```python
23
+ from sillydev import SillyDev
24
+
25
+ client = SillyDev() # or SillyDev(api_key="sdevc_...")
26
+
27
+ for server in client.panel.servers.list():
28
+ print(server["identifier"], server["name"])
29
+
30
+ client.panel.servers.power("1a7ce997", "restart")
31
+ client.panel.servers.command("1a7ce997", "say Back in a minute")
32
+ ```
33
+
34
+ Each server has an 8-character identifier, shown in the panel and in the `identifier` field of
35
+ every server. Every method takes it (or the full UUID) as its first argument.
36
+
37
+ ## Examples
38
+
39
+ ```python
40
+ from sillydev import SillyDev
41
+
42
+ client = SillyDev()
43
+ panel = client.panel
44
+ server = "1a7ce997"
45
+
46
+ # Live state and resource use
47
+ stats = panel.servers.resources(server)
48
+ print(stats["current_state"], stats["resources"]["memory_bytes"])
49
+
50
+ # Files
51
+ for f in panel.files.list(server, directory="/"):
52
+ print(f["name"], f["size"])
53
+ config = panel.files.read(server, "/config.json")
54
+ panel.files.write(server, "/config.json", config.replace("debug", "info"))
55
+
56
+ # Backups
57
+ backup = panel.backups.create(server, name="before-update")
58
+ print(backup["uuid"])
59
+
60
+ # Deploy the linked Git repository
61
+ deployment = panel.git.deploy(server)
62
+ print(deployment["status"]) # "queued"
63
+
64
+ # Startup variables
65
+ panel.startup.set_variable(server, "MAIN_FILE", "bot.py")
66
+ ```
67
+
68
+ ### Responses
69
+
70
+ Methods return plain dicts and lists. The API's `{"object": ..., "attributes": {...}}` envelopes
71
+ are removed, so `panel.servers.get(server)["name"]` just works.
72
+
73
+ ### Pagination
74
+
75
+ `panel.servers.list()`, `panel.backups.list()`, `panel.servers.activity()` and
76
+ `panel.account.activity()` return iterators that fetch the next page as you go. For one page at a
77
+ time, with the list's `meta`, use the `*_page` methods:
78
+
79
+ ```python
80
+ page = panel.servers.list_page(page=1, per_page=25)
81
+ print(page.total, page.has_next, page.meta.get("pending_orders"))
82
+ ```
83
+
84
+ ### Async
85
+
86
+ ```python
87
+ import asyncio
88
+ from sillydev import AsyncSillyDev
89
+
90
+ async def main():
91
+ async with AsyncSillyDev() as client:
92
+ async for server in client.panel.servers.list():
93
+ print(server["name"])
94
+ await client.panel.servers.restart("1a7ce997")
95
+
96
+ asyncio.run(main())
97
+ ```
98
+
99
+ ### Errors
100
+
101
+ Every error is a `sillydev.SillyDevError`. Errors the API answers with have their own class:
102
+
103
+ | Status | Exception |
104
+ | --- | --- |
105
+ | 400 | `BadRequestError` |
106
+ | 401 | `AuthenticationError` |
107
+ | 403 | `PermissionDeniedError` |
108
+ | 404 | `NotFoundError` |
109
+ | 409 | `ConflictError` |
110
+ | 422 | `ValidationError` (`.errors` has every problem, `.fields` groups them by field) |
111
+ | 429 | `RateLimitError` (`.retry_after` in seconds) |
112
+ | 5xx | `ServerError` |
113
+
114
+ If the API cannot be reached at all you get `APIConnectionError`.
115
+
116
+ ```python
117
+ from sillydev import ConflictError, NotFoundError
118
+
119
+ try:
120
+ panel.servers.restart(server)
121
+ except ConflictError:
122
+ print("The server is installing or being transferred; try again later")
123
+ except NotFoundError:
124
+ print("No such server, or the key cannot reach it")
125
+ ```
126
+
127
+ ### Retries and limits
128
+
129
+ Each account may make 768 requests a minute. Requests answered 429 are retried
130
+ twice by default, and reads answered 502, 503 or 504 too (a command or power action is not
131
+ repeated, since the server may already have run it), waiting as long as the `Retry-After` header asks. Change it with
132
+ `SillyDev(max_retries=...)`; `0` turns retries off.
133
+
134
+ Ordering a paid server (`panel.billing.checkout(...)`) always sends an `Idempotency-Key`, so a
135
+ retried request never buys twice. Pass `idempotency_key=` yourself to make retries safe across runs.
136
+
137
+ ### Everything else
138
+
139
+ `client.panel` has one attribute for each area of the API:
140
+
141
+ | Attribute | What it covers |
142
+ | --- | --- |
143
+ | `servers` | list, get, delete, resources, activity, permissions, power, command, share logs, websocket |
144
+ | `settings` | rename, reinstall, Docker image, status badge |
145
+ | `startup` | startup command and variables |
146
+ | `files` | list, read, write, rename, copy, compress, decompress, delete, folders, chmod, pull, signed URLs |
147
+ | `backups` | list, create, get, delete, download, lock, restore |
148
+ | `schedules` | schedules and their tasks |
149
+ | `network` | allocations (ports) |
150
+ | `subusers` | other accounts with access to a server |
151
+ | `git` | link a repository, deploy, deployments, `sillydev.conf` |
152
+ | `account` | the key's account and its activity |
153
+ | `server_creation` | create free servers |
154
+ | `databases` | free MariaDB and Postgres databases |
155
+ | `billing` | paid servers and subscriptions |
156
+
157
+ Every method's docstring names the API operation it calls, so you can look it up in the
158
+ [API reference](https://sillydev.co.uk/docs/panel).
159
+
160
+ ## Command line
161
+
162
+ ```sh
163
+ export SILLYDEV_API_KEY="sdevc_..."
164
+
165
+ sillydev servers list
166
+ sillydev status 1a7ce997
167
+ sillydev power 1a7ce997 restart
168
+ sillydev command 1a7ce997 "say hi"
169
+ sillydev deploy 1a7ce997
170
+ sillydev files ls 1a7ce997 /src
171
+ sillydev files cat 1a7ce997 /config.json
172
+ sillydev backups list 1a7ce997
173
+ sillydev backups create 1a7ce997 --name before-update
174
+ ```
175
+
176
+ Add `--json` to any command for JSON output. `python -m sillydev` works too.
177
+
178
+ ## MCP server
179
+
180
+ The MCP server lets an AI assistant (Claude Desktop, Claude Code, Cursor and others) check on and
181
+ control your servers. It needs Python 3.10 or later:
182
+
183
+ ```sh
184
+ pip install 'sillydev[mcp]'
185
+ ```
186
+
187
+ Then add it to your assistant's MCP settings, for example:
188
+
189
+ ```json
190
+ {
191
+ "mcpServers": {
192
+ "sillydev": {
193
+ "command": "sillydev-mcp",
194
+ "env": { "SILLYDEV_API_KEY": "sdevc_..." }
195
+ }
196
+ }
197
+ }
198
+ ```
199
+
200
+ Its tools are: list servers, server status, power action, send command, list files, read file,
201
+ Git deploy and list backups. There is nothing for billing or for deleting anything. Give it a key
202
+ limited to the servers and permissions you want the assistant to have.
203
+
204
+ ## Configuration
205
+
206
+ | Option | Environment variable | Default |
207
+ | --- | --- | --- |
208
+ | `api_key` | `SILLYDEV_API_KEY` | (required) |
209
+ | `base_url` | `SILLYDEV_BASE_URL` | `https://sillydev.co.uk/panel/api/client` |
210
+ | `timeout` | | 60 seconds |
211
+ | `max_retries` | | 2 |
212
+
213
+ ## License
214
+
215
+ MIT
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "sillydev"
7
+ dynamic = ["version"]
8
+ description = "Python client, CLI and MCP server for the Silly Development panel API."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Silly Development" }]
14
+ keywords = ["sillydev", "silly development", "bot hosting", "api", "sdk", "mcp"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Typing :: Typed",
28
+ ]
29
+ dependencies = ["httpx>=0.23,<1"]
30
+
31
+ [project.optional-dependencies]
32
+ mcp = ["mcp>=1.2; python_version >= '3.10'"]
33
+ dev = [
34
+ "pytest>=7",
35
+ "respx>=0.20",
36
+ "mcp>=1.2; python_version >= '3.10'",
37
+ ]
38
+
39
+ [project.scripts]
40
+ sillydev = "sillydev.cli:main"
41
+ sillydev-mcp = "sillydev.mcp_server:main"
42
+
43
+ [project.urls]
44
+ Homepage = "https://sillydev.co.uk"
45
+ Documentation = "https://sillydev.co.uk/docs/panel"
46
+ Source = "https://github.com/TheGamer3514/silly-development/tree/main/sdk/python"
47
+
48
+ [tool.hatch.version]
49
+ path = "src/sillydev/_version.py"
50
+
51
+ [tool.hatch.build.targets.wheel]
52
+ packages = ["src/sillydev"]
53
+
54
+ [tool.hatch.build.targets.sdist]
55
+ include = ["src/sillydev", "tests", "scripts", "README.md", "LICENSE", "pyproject.toml"]
56
+
57
+ [tool.pytest.ini_options]
58
+ testpaths = ["tests"]
@@ -0,0 +1,88 @@
1
+ """Write src/sillydev/_async_resources.py from src/sillydev/resources.py.
2
+
3
+ The async resources are the sync ones with ``async``/``await`` added, so they are generated
4
+ rather than kept by hand. Run ``python scripts/unasync.py`` after changing resources.py;
5
+ ``tests/test_unasync.py`` fails while the two are out of step. ``--check`` only compares.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import re
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ SRC = Path(__file__).resolve().parent.parent / "src" / "sillydev"
15
+ SYNC = SRC / "resources.py"
16
+ ASYNC = SRC / "_async_resources.py"
17
+
18
+ # Calls that are coroutines in the async client, so need awaiting.
19
+ AWAITED = ("self._client._request(", "self._client._page(", "self.power(")
20
+
21
+ HEADER = '''"""Async versions of the resources in ``resources.py``.
22
+
23
+ GENERATED by ``scripts/unasync.py`` from ``resources.py``: do not edit by hand.
24
+ """
25
+ '''
26
+
27
+
28
+ def convert(source: str) -> str:
29
+ classes = re.findall(r"^class (\w+)\(", source, flags=re.M)
30
+ classes += ["Panel"] if "Panel" not in classes else []
31
+
32
+ # Split into top-level/method chunks so that each def can be judged on its own body.
33
+ lines = source.splitlines(keepends=True)
34
+ out = []
35
+ i = 0
36
+ def_re = re.compile(r"^(\s*)def (\w+)\(")
37
+ while i < len(lines):
38
+ match = def_re.match(lines[i])
39
+ if not match:
40
+ out.append(lines[i])
41
+ i += 1
42
+ continue
43
+ indent = match.group(1)
44
+ j = i + 1
45
+ while j < len(lines) and (
46
+ lines[j].strip() == "" or lines[j].startswith(indent + " ") or lines[j].startswith(indent + ")")
47
+ ):
48
+ j += 1
49
+ # Trailing blank lines belong to whatever follows.
50
+ while j > i + 1 and lines[j - 1].strip() == "":
51
+ j -= 1
52
+ chunk = "".join(lines[i:j])
53
+ if any(call in chunk for call in AWAITED) and not chunk.lstrip().startswith("def _"):
54
+ chunk = chunk.replace(indent + "def ", indent + "async def ", 1)
55
+ for call in AWAITED:
56
+ chunk = chunk.replace(call, "await " + call)
57
+ out.append(chunk)
58
+ i = j
59
+ text = "".join(out)
60
+
61
+ text = text.replace("Iterator[JSON]", "AsyncIterator[JSON]")
62
+ text = text.replace("Iterable, Iterator,", "AsyncIterator, Iterable,")
63
+ text = text.replace("from ._client import SillyDev", "from ._client import AsyncSillyDev")
64
+ text = text.replace('client: "SillyDev"', 'client: "AsyncSillyDev"')
65
+ for name in sorted(set(classes), key=len, reverse=True):
66
+ public = name.lstrip("_")
67
+ prefix = "_" if name.startswith("_") else ""
68
+ text = re.sub(rf"(?<![\w.\"]){re.escape(name)}\b(?=\(|:|\]|,|\n|\"|$)", f"{prefix}Async{public}", text)
69
+ # The module docstring and __all__ of the sync file describe that file.
70
+ text = re.sub(r'\A""".*?"""\n', HEADER, text, count=1, flags=re.S)
71
+ text = re.sub(r'"(\w+)",\n', lambda m: f'"Async{m.group(1)}",\n' if m.group(1) in classes else m.group(0), text)
72
+ return text
73
+
74
+
75
+ def main(argv: list) -> int:
76
+ generated = convert(SYNC.read_text())
77
+ if "--check" in argv:
78
+ if not ASYNC.exists() or ASYNC.read_text() != generated:
79
+ print(f"{ASYNC.name} is out of date; run python scripts/unasync.py", file=sys.stderr)
80
+ return 1
81
+ return 0
82
+ ASYNC.write_text(generated)
83
+ print(f"wrote {ASYNC}")
84
+ return 0
85
+
86
+
87
+ if __name__ == "__main__":
88
+ sys.exit(main(sys.argv[1:]))
@@ -0,0 +1,45 @@
1
+ """Python client for the Silly Development panel API.
2
+
3
+ >>> from sillydev import SillyDev
4
+ >>> client = SillyDev() # reads SILLYDEV_API_KEY
5
+ >>> client.panel.servers.restart("1a7ce997")
6
+
7
+ Docs: https://sillydev.co.uk/docs/panel
8
+ """
9
+
10
+ from ._client import DEFAULT_BASE_URL, AsyncSillyDev, SillyDev
11
+ from ._envelope import Page, unwrap
12
+ from ._errors import (
13
+ APIConnectionError,
14
+ APIStatusError,
15
+ AuthenticationError,
16
+ BadRequestError,
17
+ ConflictError,
18
+ NotFoundError,
19
+ PermissionDeniedError,
20
+ RateLimitError,
21
+ ServerError,
22
+ SillyDevError,
23
+ ValidationError,
24
+ )
25
+ from ._version import __version__
26
+
27
+ __all__ = [
28
+ "SillyDev",
29
+ "AsyncSillyDev",
30
+ "DEFAULT_BASE_URL",
31
+ "Page",
32
+ "unwrap",
33
+ "SillyDevError",
34
+ "APIConnectionError",
35
+ "APIStatusError",
36
+ "BadRequestError",
37
+ "AuthenticationError",
38
+ "PermissionDeniedError",
39
+ "NotFoundError",
40
+ "ConflictError",
41
+ "ValidationError",
42
+ "RateLimitError",
43
+ "ServerError",
44
+ "__version__",
45
+ ]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())