pieforhead 0.0.1__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.
- pieforhead-0.0.1/.gitignore +220 -0
- pieforhead-0.0.1/LICENSE +24 -0
- pieforhead-0.0.1/PKG-INFO +119 -0
- pieforhead-0.0.1/README.md +101 -0
- pieforhead-0.0.1/docs/index.md +17 -0
- pieforhead-0.0.1/logo.png +0 -0
- pieforhead-0.0.1/mkdocs.yml +1 -0
- pieforhead-0.0.1/pyproject.toml +44 -0
- pieforhead-0.0.1/src/pieforhead/__init__.py +4 -0
- pieforhead-0.0.1/src/pieforhead/clients.py +481 -0
- pieforhead-0.0.1/src/pieforhead/exceptions.py +14 -0
- pieforhead-0.0.1/src/pieforhead/image.py +185 -0
- pieforhead-0.0.1/src/pieforhead/pieforhead.py +79 -0
- pieforhead-0.0.1/src/pieforhead/site.py +142 -0
- pieforhead-0.0.1/src/pieforhead/utils.py +1 -0
- pieforhead-0.0.1/tests/test_client.py +157 -0
- pieforhead-0.0.1/tests/test_client_async.py +182 -0
- pieforhead-0.0.1/tests/test_image.py +243 -0
- pieforhead-0.0.1/tests/test_image_async.py +292 -0
- pieforhead-0.0.1/tests/test_site.py +119 -0
- pieforhead-0.0.1/tests/test_site_async.py +151 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
*.lcov
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
# Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# uv
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
# poetry.lock
|
|
110
|
+
# poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
# pdm.lock
|
|
117
|
+
# pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
# pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi/*
|
|
127
|
+
!.pixi/config.toml
|
|
128
|
+
|
|
129
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
130
|
+
__pypackages__/
|
|
131
|
+
|
|
132
|
+
# Celery stuff
|
|
133
|
+
celerybeat-schedule*
|
|
134
|
+
celerybeat.pid
|
|
135
|
+
|
|
136
|
+
# Redis
|
|
137
|
+
*.rdb
|
|
138
|
+
*.aof
|
|
139
|
+
*.pid
|
|
140
|
+
|
|
141
|
+
# RabbitMQ
|
|
142
|
+
mnesia/
|
|
143
|
+
rabbitmq/
|
|
144
|
+
rabbitmq-data/
|
|
145
|
+
|
|
146
|
+
# ActiveMQ
|
|
147
|
+
activemq-data/
|
|
148
|
+
|
|
149
|
+
# SageMath parsed files
|
|
150
|
+
*.sage.py
|
|
151
|
+
|
|
152
|
+
# Environments
|
|
153
|
+
.env
|
|
154
|
+
.envrc
|
|
155
|
+
.venv
|
|
156
|
+
env/
|
|
157
|
+
venv/
|
|
158
|
+
ENV/
|
|
159
|
+
env.bak/
|
|
160
|
+
venv.bak/
|
|
161
|
+
|
|
162
|
+
# Spyder project settings
|
|
163
|
+
.spyderproject
|
|
164
|
+
.spyproject
|
|
165
|
+
|
|
166
|
+
# Rope project settings
|
|
167
|
+
.ropeproject
|
|
168
|
+
|
|
169
|
+
# mkdocs/Zensical documentation
|
|
170
|
+
/site
|
|
171
|
+
|
|
172
|
+
# mypy
|
|
173
|
+
.mypy_cache/
|
|
174
|
+
.dmypy.json
|
|
175
|
+
dmypy.json
|
|
176
|
+
|
|
177
|
+
# Pyre type checker
|
|
178
|
+
.pyre/
|
|
179
|
+
|
|
180
|
+
# pytype static type analyzer
|
|
181
|
+
.pytype/
|
|
182
|
+
|
|
183
|
+
# Cython debug symbols
|
|
184
|
+
cython_debug/
|
|
185
|
+
|
|
186
|
+
# PyCharm
|
|
187
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
188
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
189
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
190
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
191
|
+
# .idea/
|
|
192
|
+
|
|
193
|
+
# Abstra
|
|
194
|
+
# Abstra is an AI-powered process automation framework.
|
|
195
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
196
|
+
# Learn more at https://abstra.io/docs
|
|
197
|
+
.abstra/
|
|
198
|
+
|
|
199
|
+
# Visual Studio Code
|
|
200
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
|
|
201
|
+
# can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
202
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer, you
|
|
203
|
+
# could uncomment the following to ignore the entire vscode folder
|
|
204
|
+
.vscode/
|
|
205
|
+
# Temporary file for partial code execution
|
|
206
|
+
tempCodeRunnerFile.py
|
|
207
|
+
|
|
208
|
+
# Ruff stuff:
|
|
209
|
+
.ruff_cache/
|
|
210
|
+
|
|
211
|
+
# PyPI configuration file
|
|
212
|
+
.pypirc
|
|
213
|
+
|
|
214
|
+
# Marimo
|
|
215
|
+
marimo/_static/
|
|
216
|
+
marimo/_lsp/
|
|
217
|
+
__marimo__/
|
|
218
|
+
|
|
219
|
+
# Streamlit
|
|
220
|
+
.streamlit/secrets.toml
|
pieforhead-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pieforhead
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A python library for interacting with the PieFed API
|
|
5
|
+
Project-URL: Homepage, https://github.com/wjs018/pieforhead
|
|
6
|
+
Project-URL: Issues, https://github.com/wjs018/pieforhead/issues
|
|
7
|
+
Author-email: wjs018 <wjs018@gmail.com>
|
|
8
|
+
License-Expression: Unlicense
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: fediverse,piefed
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Requires-Dist: httpx
|
|
16
|
+
Requires-Dist: semver
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# pieforhead
|
|
20
|
+
|
|
21
|
+
A python wrapper for the PieFed API supporting both synchronous and asynchronous usage. This is an early work in progress, and few endpoints are supported yet.
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
## Usage Notes
|
|
26
|
+
|
|
27
|
+
In general, all successful requests to the server should return a `dict` with the server's json response. Due to the alpha nature of the PieFed API, the maintenance burden of creating and updating response models as features/fields are added to the API is a burden that I don't want to take on at this time. Please refer to the official PieFed OpenAPI specification ([stable version](https://stable.wjs018.xyz/api/alpha/swagger), [development version](https://crust.piefed.social/api/alpha/swagger)) to see what your code should expect as a response.
|
|
28
|
+
|
|
29
|
+
By default, exceptions will be raised if something goes wrong (e.g. malformed request, network timeout, 5XX errors, etc.) to provide a trace. However, to suppress these exceptions, you can pass the `raise_exceptions=False` keyword argument when instantiating your client. This will cause a returned value of `None` instead of raising an exception. Please make sure that your code handles such a case appropriately.
|
|
30
|
+
|
|
31
|
+
## Synchronous Client Usage
|
|
32
|
+
|
|
33
|
+
Users familiar with network libraries like `requests` would probably be most familiar with synchronous usage. However, to make network requests a bit more efficient, this library makes use of `Client`s within `httpx` where you can take advantage of connection pooling for multiple network requests. This means that when you instantiate a `PieFed` class, it is best practice to close it when you are done with it. Here are a couple examples that show how this can be done.
|
|
34
|
+
|
|
35
|
+
These snippets all do the same three things:
|
|
36
|
+
|
|
37
|
+
1. Create a `PieFed` object with the given instance url (this creates the client)
|
|
38
|
+
2. Log in using a username and password
|
|
39
|
+
3. Close the client after we no longer need it
|
|
40
|
+
|
|
41
|
+
Closing it manually using the `close` function:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from piefedhead import PieFed
|
|
45
|
+
|
|
46
|
+
piefed = PieFed("https://instance.tld")
|
|
47
|
+
piefed.log_in("username", "password")
|
|
48
|
+
|
|
49
|
+
piefed.close()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Using a context manager (a `with` block):
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
# Inside a context manager
|
|
56
|
+
with PieFed("https://instance.tld") as piefed:
|
|
57
|
+
piefed.log_in("username", "password")
|
|
58
|
+
|
|
59
|
+
# The connection is closed after leaving the `with` block
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Using a callback that ensures the `close` function is called when execution has ended:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# Registering an event handler
|
|
66
|
+
import atexit
|
|
67
|
+
|
|
68
|
+
piefed = PieFed("https://instance.tld")
|
|
69
|
+
atexit.register(piefed.close) # Automatically closes the client at program termination
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Asynchronous Client Usage
|
|
73
|
+
|
|
74
|
+
To use this libray in an async manner, there is a separate client, `PieFedAsync` that should be used. Everything else should work exactly the same as the synchronous client, except that results will need to be `await`ed.
|
|
75
|
+
|
|
76
|
+
Here is a snippet that does the same three actions as outlined above for the synchronous client, but using the `PieFedAsync` client.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
# Put things in an async function so that we can use the await keyword
|
|
80
|
+
async def main():
|
|
81
|
+
piefed_async = PieFedAsync("https://instance.tld")
|
|
82
|
+
await piefed_async.log_in("username", "password") # Notice the await keyword
|
|
83
|
+
|
|
84
|
+
await piefed_async.close()
|
|
85
|
+
|
|
86
|
+
# Start the event loop and execute the async function
|
|
87
|
+
asyncio.run(main())
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Similar to the synchronous client, you can also use a context handler to automatically close the async client:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
async def main():
|
|
94
|
+
async with PieFedAsync("https://instance.tld") as piefed_async:
|
|
95
|
+
await piefed_async.log_in("username", "password")
|
|
96
|
+
|
|
97
|
+
# Client is closed automatically once outside the context handler
|
|
98
|
+
|
|
99
|
+
# Start the event loop and execute the async function
|
|
100
|
+
asyncio.run(main())
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Endpoint Coverage
|
|
104
|
+
|
|
105
|
+
This project is in an early stage. Here is a high level summary of where things stand with implementing the wrapper around different PieFed API endpoint groups:
|
|
106
|
+
|
|
107
|
+
| Endpoint Group | Sync Client | Async Client | Notes |
|
|
108
|
+
| :-------------: | :---------: | :----------: | :--------------------------------------- |
|
|
109
|
+
| Site | ✅ | ✅ | Instance chooser endpoints unimplemented |
|
|
110
|
+
| Upload | ✅ | ✅ | |
|
|
111
|
+
| User | 🟡 | 🟡 | Auth endpoints implemented |
|
|
112
|
+
| Post | ❌ | ❌ | |
|
|
113
|
+
| Comment | ❌ | ❌ | |
|
|
114
|
+
| Community | ❌ | ❌ | |
|
|
115
|
+
| Feed | ❌ | ❌ | |
|
|
116
|
+
| Topic | ❌ | ❌ | |
|
|
117
|
+
| Private Message | ❌ | ❌ | |
|
|
118
|
+
| Admin | ❌ | ❌ | |
|
|
119
|
+
| Misc. | ❌ | ❌ | |
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# pieforhead
|
|
2
|
+
|
|
3
|
+
A python wrapper for the PieFed API supporting both synchronous and asynchronous usage. This is an early work in progress, and few endpoints are supported yet.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Usage Notes
|
|
8
|
+
|
|
9
|
+
In general, all successful requests to the server should return a `dict` with the server's json response. Due to the alpha nature of the PieFed API, the maintenance burden of creating and updating response models as features/fields are added to the API is a burden that I don't want to take on at this time. Please refer to the official PieFed OpenAPI specification ([stable version](https://stable.wjs018.xyz/api/alpha/swagger), [development version](https://crust.piefed.social/api/alpha/swagger)) to see what your code should expect as a response.
|
|
10
|
+
|
|
11
|
+
By default, exceptions will be raised if something goes wrong (e.g. malformed request, network timeout, 5XX errors, etc.) to provide a trace. However, to suppress these exceptions, you can pass the `raise_exceptions=False` keyword argument when instantiating your client. This will cause a returned value of `None` instead of raising an exception. Please make sure that your code handles such a case appropriately.
|
|
12
|
+
|
|
13
|
+
## Synchronous Client Usage
|
|
14
|
+
|
|
15
|
+
Users familiar with network libraries like `requests` would probably be most familiar with synchronous usage. However, to make network requests a bit more efficient, this library makes use of `Client`s within `httpx` where you can take advantage of connection pooling for multiple network requests. This means that when you instantiate a `PieFed` class, it is best practice to close it when you are done with it. Here are a couple examples that show how this can be done.
|
|
16
|
+
|
|
17
|
+
These snippets all do the same three things:
|
|
18
|
+
|
|
19
|
+
1. Create a `PieFed` object with the given instance url (this creates the client)
|
|
20
|
+
2. Log in using a username and password
|
|
21
|
+
3. Close the client after we no longer need it
|
|
22
|
+
|
|
23
|
+
Closing it manually using the `close` function:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from piefedhead import PieFed
|
|
27
|
+
|
|
28
|
+
piefed = PieFed("https://instance.tld")
|
|
29
|
+
piefed.log_in("username", "password")
|
|
30
|
+
|
|
31
|
+
piefed.close()
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Using a context manager (a `with` block):
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
# Inside a context manager
|
|
38
|
+
with PieFed("https://instance.tld") as piefed:
|
|
39
|
+
piefed.log_in("username", "password")
|
|
40
|
+
|
|
41
|
+
# The connection is closed after leaving the `with` block
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Using a callback that ensures the `close` function is called when execution has ended:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
# Registering an event handler
|
|
48
|
+
import atexit
|
|
49
|
+
|
|
50
|
+
piefed = PieFed("https://instance.tld")
|
|
51
|
+
atexit.register(piefed.close) # Automatically closes the client at program termination
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Asynchronous Client Usage
|
|
55
|
+
|
|
56
|
+
To use this libray in an async manner, there is a separate client, `PieFedAsync` that should be used. Everything else should work exactly the same as the synchronous client, except that results will need to be `await`ed.
|
|
57
|
+
|
|
58
|
+
Here is a snippet that does the same three actions as outlined above for the synchronous client, but using the `PieFedAsync` client.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
# Put things in an async function so that we can use the await keyword
|
|
62
|
+
async def main():
|
|
63
|
+
piefed_async = PieFedAsync("https://instance.tld")
|
|
64
|
+
await piefed_async.log_in("username", "password") # Notice the await keyword
|
|
65
|
+
|
|
66
|
+
await piefed_async.close()
|
|
67
|
+
|
|
68
|
+
# Start the event loop and execute the async function
|
|
69
|
+
asyncio.run(main())
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Similar to the synchronous client, you can also use a context handler to automatically close the async client:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
async def main():
|
|
76
|
+
async with PieFedAsync("https://instance.tld") as piefed_async:
|
|
77
|
+
await piefed_async.log_in("username", "password")
|
|
78
|
+
|
|
79
|
+
# Client is closed automatically once outside the context handler
|
|
80
|
+
|
|
81
|
+
# Start the event loop and execute the async function
|
|
82
|
+
asyncio.run(main())
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Endpoint Coverage
|
|
86
|
+
|
|
87
|
+
This project is in an early stage. Here is a high level summary of where things stand with implementing the wrapper around different PieFed API endpoint groups:
|
|
88
|
+
|
|
89
|
+
| Endpoint Group | Sync Client | Async Client | Notes |
|
|
90
|
+
| :-------------: | :---------: | :----------: | :--------------------------------------- |
|
|
91
|
+
| Site | ✅ | ✅ | Instance chooser endpoints unimplemented |
|
|
92
|
+
| Upload | ✅ | ✅ | |
|
|
93
|
+
| User | 🟡 | 🟡 | Auth endpoints implemented |
|
|
94
|
+
| Post | ❌ | ❌ | |
|
|
95
|
+
| Comment | ❌ | ❌ | |
|
|
96
|
+
| Community | ❌ | ❌ | |
|
|
97
|
+
| Feed | ❌ | ❌ | |
|
|
98
|
+
| Topic | ❌ | ❌ | |
|
|
99
|
+
| Private Message | ❌ | ❌ | |
|
|
100
|
+
| Admin | ❌ | ❌ | |
|
|
101
|
+
| Misc. | ❌ | ❌ | |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Welcome to MkDocs
|
|
2
|
+
|
|
3
|
+
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
* `mkdocs new [dir-name]` - Create a new project.
|
|
8
|
+
* `mkdocs serve` - Start the live-reloading docs server.
|
|
9
|
+
* `mkdocs build` - Build the documentation site.
|
|
10
|
+
* `mkdocs -h` - Print help message and exit.
|
|
11
|
+
|
|
12
|
+
## Project layout
|
|
13
|
+
|
|
14
|
+
mkdocs.yml # The configuration file.
|
|
15
|
+
docs/
|
|
16
|
+
index.md # The documentation homepage.
|
|
17
|
+
... # Other markdown pages, images and other files.
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
site_name: My Docs
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pieforhead"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "wjs018", email = "wjs018@gmail.com"},
|
|
10
|
+
]
|
|
11
|
+
description = "A python library for interacting with the PieFed API"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
keywords = ["piefed", "fediverse"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
19
|
+
]
|
|
20
|
+
license = "Unlicense"
|
|
21
|
+
license-files = ["LICENSE"]
|
|
22
|
+
dependencies =[
|
|
23
|
+
"httpx",
|
|
24
|
+
"semver",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[tool.hatch.version]
|
|
28
|
+
path = "src/pieforhead/utils.py"
|
|
29
|
+
|
|
30
|
+
[tool.hatch.build]
|
|
31
|
+
exclude = ["/test_*"]
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.wheel]
|
|
34
|
+
exclude = ["tests/**", "docs/**", "mkdocs.yml"]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/wjs018/pieforhead"
|
|
38
|
+
Issues = "https://github.com/wjs018/pieforhead/issues"
|
|
39
|
+
|
|
40
|
+
[tool.ruff]
|
|
41
|
+
line-length = 119
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
pythonpath = ["src"]
|