aioseafile 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.
- aioseafile-0.1.0/.gitignore +133 -0
- aioseafile-0.1.0/LICENSE +21 -0
- aioseafile-0.1.0/PKG-INFO +219 -0
- aioseafile-0.1.0/README.md +190 -0
- aioseafile-0.1.0/pyproject.toml +181 -0
- aioseafile-0.1.0/src/aioseafile/__init__.py +361 -0
- aioseafile-0.1.0/src/aioseafile/client.py +310 -0
- aioseafile-0.1.0/src/aioseafile/endpoints/__init__.py +1 -0
- aioseafile-0.1.0/src/aioseafile/endpoints/account.py +273 -0
- aioseafile-0.1.0/src/aioseafile/endpoints/admin.py +535 -0
- aioseafile-0.1.0/src/aioseafile/endpoints/extras.py +720 -0
- aioseafile-0.1.0/src/aioseafile/endpoints/files.py +456 -0
- aioseafile-0.1.0/src/aioseafile/endpoints/groups.py +388 -0
- aioseafile-0.1.0/src/aioseafile/endpoints/libraries.py +512 -0
- aioseafile-0.1.0/src/aioseafile/endpoints/sharing.py +588 -0
- aioseafile-0.1.0/src/aioseafile/exceptions.py +29 -0
- aioseafile-0.1.0/src/aioseafile/models/__init__.py +1 -0
- aioseafile-0.1.0/src/aioseafile/models/account.py +232 -0
- aioseafile-0.1.0/src/aioseafile/models/admin.py +414 -0
- aioseafile-0.1.0/src/aioseafile/models/common.py +24 -0
- aioseafile-0.1.0/src/aioseafile/models/extras.py +384 -0
- aioseafile-0.1.0/src/aioseafile/models/files.py +176 -0
- aioseafile-0.1.0/src/aioseafile/models/groups.py +236 -0
- aioseafile-0.1.0/src/aioseafile/models/libraries.py +344 -0
- aioseafile-0.1.0/src/aioseafile/models/sharing.py +378 -0
- aioseafile-0.1.0/src/aioseafile/py.typed +0 -0
- aioseafile-0.1.0/src/aioseafile/seafile.py +21 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
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
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
|
|
53
|
+
# Translations
|
|
54
|
+
*.mo
|
|
55
|
+
*.pot
|
|
56
|
+
|
|
57
|
+
# Django stuff:
|
|
58
|
+
*.log
|
|
59
|
+
local_settings.py
|
|
60
|
+
db.sqlite3
|
|
61
|
+
|
|
62
|
+
# Flask stuff:
|
|
63
|
+
instance/
|
|
64
|
+
.webassets-cache
|
|
65
|
+
|
|
66
|
+
# Scrapy stuff:
|
|
67
|
+
.scrapy
|
|
68
|
+
|
|
69
|
+
# Sphinx documentation
|
|
70
|
+
docs/_build/
|
|
71
|
+
|
|
72
|
+
# PyBuilder
|
|
73
|
+
target/
|
|
74
|
+
|
|
75
|
+
# Jupyter Notebook
|
|
76
|
+
.ipynb_checkpoints
|
|
77
|
+
|
|
78
|
+
# IPython
|
|
79
|
+
profile_default/
|
|
80
|
+
ipython_config.py
|
|
81
|
+
|
|
82
|
+
# pyenv
|
|
83
|
+
.python-version
|
|
84
|
+
|
|
85
|
+
# pipenv
|
|
86
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
87
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
88
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
89
|
+
# install all needed dependencies.
|
|
90
|
+
#Pipfile.lock
|
|
91
|
+
|
|
92
|
+
# celery beat schedule file
|
|
93
|
+
celerybeat-schedule
|
|
94
|
+
|
|
95
|
+
# SageMath parsed files
|
|
96
|
+
*.sage.py
|
|
97
|
+
|
|
98
|
+
# Environments
|
|
99
|
+
.env
|
|
100
|
+
.venv
|
|
101
|
+
env/
|
|
102
|
+
venv/
|
|
103
|
+
ENV/
|
|
104
|
+
env.bak/
|
|
105
|
+
venv.bak/
|
|
106
|
+
|
|
107
|
+
# Spyder project settings
|
|
108
|
+
.spyderproject
|
|
109
|
+
.spyproject
|
|
110
|
+
|
|
111
|
+
# Rope project settings
|
|
112
|
+
.ropeproject
|
|
113
|
+
|
|
114
|
+
# mkdocs documentation
|
|
115
|
+
/site
|
|
116
|
+
|
|
117
|
+
# mypy
|
|
118
|
+
.mypy_cache/
|
|
119
|
+
|
|
120
|
+
# Visual Studio Code
|
|
121
|
+
.vscode
|
|
122
|
+
|
|
123
|
+
# ruff
|
|
124
|
+
.ruff_cache
|
|
125
|
+
|
|
126
|
+
# Pyre type checker
|
|
127
|
+
.pyre/
|
|
128
|
+
|
|
129
|
+
setup.py
|
|
130
|
+
.python-version
|
|
131
|
+
|
|
132
|
+
# Examples
|
|
133
|
+
examples/example_dev.py
|
aioseafile-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Erwin Douna
|
|
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,219 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: aioseafile
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Asynchronous Python client for the Seafile Web API
|
|
5
|
+
Project-URL: Homepage, https://github.com/erwindouna/aioseafile
|
|
6
|
+
Project-URL: Repository, https://github.com/erwindouna/aioseafile
|
|
7
|
+
Project-URL: Documentation, https://github.com/erwindouna/aioseafile
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/erwindouna/aioseafile/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/erwindouna/aioseafile/releases
|
|
10
|
+
Author-email: Erwin Douna <e.douna@gmail.com>
|
|
11
|
+
Maintainer-email: Erwin Douna <e.douna@gmail.com>
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: api,async,client,seafile
|
|
15
|
+
Classifier: Framework :: AsyncIO
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Natural Language :: English
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: <4,>=3.14
|
|
23
|
+
Requires-Dist: aiohttp>=3.0.0
|
|
24
|
+
Requires-Dist: mashumaro<4,>=3.17
|
|
25
|
+
Requires-Dist: orjson<4,>=3.10.16
|
|
26
|
+
Requires-Dist: tenacity>=9.0.0
|
|
27
|
+
Requires-Dist: yarl>=1.6.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
<!-- PROJECT SHIELDS -->
|
|
31
|
+
|
|
32
|
+
[![GitHub Release][releases-shield]][releases]
|
|
33
|
+
[![Python Versions][python-versions-shield]][pypi]
|
|
34
|
+
![Project Stage][project-stage-shield]
|
|
35
|
+
![Project Maintenance][maintenance-shield]
|
|
36
|
+
[![License][license-shield]](LICENSE)
|
|
37
|
+
|
|
38
|
+
[![GitHub Activity][commits-shield]][commits-url]
|
|
39
|
+
[![PyPi Downloads][downloads-shield]][downloads-url]
|
|
40
|
+
[![GitHub Last Commit][last-commit-shield]][commits-url]
|
|
41
|
+
[![Open in Dev Containers][devcontainer-shield]][devcontainer]
|
|
42
|
+
|
|
43
|
+
[![Build Status][build-shield]][build-url]
|
|
44
|
+
[![Typing Status][typing-shield]][typing-url]
|
|
45
|
+
[![Code Coverage][codecov-shield]][codecov-url]
|
|
46
|
+
|
|
47
|
+
Asynchronous Python client for Python Seafile.
|
|
48
|
+
|
|
49
|
+
## About
|
|
50
|
+
|
|
51
|
+
An asynchronous Python client for the [Seafile](https://www.seafile.com/) Web API, built for the Home Assistant Seafile integration. It covers the documented Seafile Web API (checked against Seafile 14), plus the system admin API:
|
|
52
|
+
|
|
53
|
+
| Area | Examples |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| Account | server info, account and quota, profile, avatar, devices, activities, notifications, guest invitations |
|
|
56
|
+
| Libraries | create, rename, transfer, delete, encryption passwords, history and snapshots, trash, deleted libraries, library API tokens and all `via-repo-token` endpoints |
|
|
57
|
+
| Files | directories, file operations, streaming upload (optionally in chunks) and download, file history, batch copy/move/delete, zip download, smart links, starred items |
|
|
58
|
+
| Sharing | share links, upload links, sharing with users and groups, folder permissions |
|
|
59
|
+
| Groups | groups, members, group libraries; departments and organizations (Pro / multi-tenancy) |
|
|
60
|
+
| Admin | system info, statistics, users, libraries, trash, devices, links, groups, logs, notifications |
|
|
61
|
+
| Extras | search, tags, file comments, wikis, metadata (Seafile 13+) |
|
|
62
|
+
|
|
63
|
+
Endpoints that only exist in the Professional edition, or that need a server setting, raise `SeafilePermissionError` or `SeafileNotFoundError` on servers without them.
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install aioseafile
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Example
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import asyncio
|
|
75
|
+
|
|
76
|
+
from aioseafile import Seafile
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
async def main() -> None:
|
|
80
|
+
"""Run the example."""
|
|
81
|
+
async with Seafile(api_url="https://cloud.example.com") as seafile:
|
|
82
|
+
await seafile.get_auth_token("me@example.com", "password")
|
|
83
|
+
account = await seafile.get_account_info()
|
|
84
|
+
print(f"{account.usage} of {account.quota_total or 'unlimited'} bytes used")
|
|
85
|
+
for library in await seafile.get_libraries():
|
|
86
|
+
print(library.name, library.size)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
asyncio.run(main())
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Pass `token=` instead of calling `get_auth_token` to reuse a stored token. Admin methods (`get_admin_*`, `create_admin_*`, ...) raise `SeafilePermissionError` for non-admin accounts.
|
|
94
|
+
|
|
95
|
+
### Uploading and downloading
|
|
96
|
+
|
|
97
|
+
Uploads and downloads are streamed, so large files never have to fit in memory. Use `chunk_size` to upload in several requests, for example behind a reverse proxy that limits the request size; each chunk is retried on transient errors.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
async def backup(seafile: Seafile, library_id: str, stream: AsyncIterator[bytes], size: int) -> None:
|
|
101
|
+
"""Upload a backup and read it back."""
|
|
102
|
+
await seafile.create_directory(library_id, "/backups")
|
|
103
|
+
await seafile.upload_file(library_id, "/backups", "backup.tar", stream, size=size, chunk_size=50 * 1024 * 1024)
|
|
104
|
+
async for chunk in seafile.download_file(library_id, "/backups/backup.tar"):
|
|
105
|
+
...
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Seafile builds upload and download links from its `SERVICE_URL` setting, which often differs from the address the client uses. The client rebases these links onto `api_url`, or onto `file_server_url` when the file server runs elsewhere.
|
|
109
|
+
|
|
110
|
+
## Contributing
|
|
111
|
+
|
|
112
|
+
This is an active open-source project. We are always open to people who want to
|
|
113
|
+
use the code or contribute to it.
|
|
114
|
+
|
|
115
|
+
We've set up a separate document for our
|
|
116
|
+
[contribution guidelines](CONTRIBUTING.md).
|
|
117
|
+
|
|
118
|
+
Thank you for being involved! :heart_eyes:
|
|
119
|
+
|
|
120
|
+
## Setting up development environment
|
|
121
|
+
|
|
122
|
+
The simplest way to begin is by utilizing the [Dev Container][devcontainer]
|
|
123
|
+
feature of Visual Studio Code or by opening a CodeSpace directly on GitHub.
|
|
124
|
+
By clicking the button below you immediately start a Dev Container in Visual Studio Code.
|
|
125
|
+
|
|
126
|
+
[![Open in Dev Containers][devcontainer-shield]][devcontainer]
|
|
127
|
+
|
|
128
|
+
This Python project relies on [UV][poetry] as its dependency manager,
|
|
129
|
+
providing comprehensive management and control over project dependencies.
|
|
130
|
+
|
|
131
|
+
### Installation
|
|
132
|
+
|
|
133
|
+
Install all packages, including all development requirements:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
uv sync --all-groups && prek install
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
_UV creates by default an virtual environment where it installs all necessary pip packages_.
|
|
140
|
+
|
|
141
|
+
### Pre-commit
|
|
142
|
+
|
|
143
|
+
This repository uses the [pre-commit][pre-commit] framework, all changes
|
|
144
|
+
are linted and tested with each commit. To setup the pre-commit check, run:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
uv run prek install
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
And to run all checks and tests manually, use the following command:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
uv run prek run --all-files
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Testing
|
|
157
|
+
|
|
158
|
+
It uses [pytest](https://docs.pytest.org/en/stable/) as the test framework. To run the tests:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
uv run pytest
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
To update the [syrupy](https://github.com/tophat/syrupy) snapshot tests:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
uv run pytest --snapshot-update
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT License
|
|
173
|
+
|
|
174
|
+
Copyright (c) 2026 Erwin Douna
|
|
175
|
+
|
|
176
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
177
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
178
|
+
in the Software without restriction, including without limitation the rights
|
|
179
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
180
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
181
|
+
furnished to do so, subject to the following conditions:
|
|
182
|
+
|
|
183
|
+
The above copyright notice and this permission notice shall be included in all
|
|
184
|
+
copies or substantial portions of the Software.
|
|
185
|
+
|
|
186
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
187
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
188
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
189
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
190
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
191
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
192
|
+
SOFTWARE.
|
|
193
|
+
|
|
194
|
+
<!-- LINKS FROM PLATFORM -->
|
|
195
|
+
|
|
196
|
+
<!-- MARKDOWN LINKS & IMAGES -->
|
|
197
|
+
|
|
198
|
+
[build-shield]: https://github.com/erwindouna/aioseafile/actions/workflows/tests.yaml/badge.svg
|
|
199
|
+
[build-url]: https://github.com/erwindouna/aioseafile/actions/workflows/tests.yaml
|
|
200
|
+
[codecov-shield]: https://codecov.io/gh/erwindouna/aioseafile/branch/main/graph/badge.svg?token=TOKEN
|
|
201
|
+
[codecov-url]: https://codecov.io/gh/erwindouna/aioseafile
|
|
202
|
+
[commits-shield]: https://img.shields.io/github/commit-activity/y/erwindouna/aioseafile.svg
|
|
203
|
+
[commits-url]: https://github.com/erwindouna/aioseafile/commits/main
|
|
204
|
+
[devcontainer-shield]: https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode
|
|
205
|
+
[devcontainer]: https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/erwindouna/aioseafile
|
|
206
|
+
[downloads-shield]: https://img.shields.io/pypi/dm/aioseafile
|
|
207
|
+
[downloads-url]: https://pypistats.org/packages/aioseafile
|
|
208
|
+
[last-commit-shield]: https://img.shields.io/github/last-commit/erwindouna/aioseafile.svg
|
|
209
|
+
[license-shield]: https://img.shields.io/github/license/erwindouna/aioseafile.svg
|
|
210
|
+
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
|
|
211
|
+
[maintenance-shield]: https://img.shields.io/maintenance/yes/2026.svg
|
|
212
|
+
[pypi]: https://pypi.org/project/aioseafile/
|
|
213
|
+
[python-versions-shield]: https://img.shields.io/pypi/pyversions/aioseafile
|
|
214
|
+
[releases-shield]: https://img.shields.io/github/release/erwindouna/aioseafile.svg
|
|
215
|
+
[releases]: https://github.com/erwindouna/aioseafile/releases
|
|
216
|
+
[typing-shield]: https://github.com/erwindouna/aioseafile/actions/workflows/typing.yaml/badge.svg
|
|
217
|
+
[typing-url]: https://github.com/erwindouna/aioseafile/actions/workflows/typing.yaml
|
|
218
|
+
[uv]: https://docs.astral.sh/uv/
|
|
219
|
+
[pre-commit]: https://pre-commit.com
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<!-- PROJECT SHIELDS -->
|
|
2
|
+
|
|
3
|
+
[![GitHub Release][releases-shield]][releases]
|
|
4
|
+
[![Python Versions][python-versions-shield]][pypi]
|
|
5
|
+
![Project Stage][project-stage-shield]
|
|
6
|
+
![Project Maintenance][maintenance-shield]
|
|
7
|
+
[![License][license-shield]](LICENSE)
|
|
8
|
+
|
|
9
|
+
[![GitHub Activity][commits-shield]][commits-url]
|
|
10
|
+
[![PyPi Downloads][downloads-shield]][downloads-url]
|
|
11
|
+
[![GitHub Last Commit][last-commit-shield]][commits-url]
|
|
12
|
+
[![Open in Dev Containers][devcontainer-shield]][devcontainer]
|
|
13
|
+
|
|
14
|
+
[![Build Status][build-shield]][build-url]
|
|
15
|
+
[![Typing Status][typing-shield]][typing-url]
|
|
16
|
+
[![Code Coverage][codecov-shield]][codecov-url]
|
|
17
|
+
|
|
18
|
+
Asynchronous Python client for Python Seafile.
|
|
19
|
+
|
|
20
|
+
## About
|
|
21
|
+
|
|
22
|
+
An asynchronous Python client for the [Seafile](https://www.seafile.com/) Web API, built for the Home Assistant Seafile integration. It covers the documented Seafile Web API (checked against Seafile 14), plus the system admin API:
|
|
23
|
+
|
|
24
|
+
| Area | Examples |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| Account | server info, account and quota, profile, avatar, devices, activities, notifications, guest invitations |
|
|
27
|
+
| Libraries | create, rename, transfer, delete, encryption passwords, history and snapshots, trash, deleted libraries, library API tokens and all `via-repo-token` endpoints |
|
|
28
|
+
| Files | directories, file operations, streaming upload (optionally in chunks) and download, file history, batch copy/move/delete, zip download, smart links, starred items |
|
|
29
|
+
| Sharing | share links, upload links, sharing with users and groups, folder permissions |
|
|
30
|
+
| Groups | groups, members, group libraries; departments and organizations (Pro / multi-tenancy) |
|
|
31
|
+
| Admin | system info, statistics, users, libraries, trash, devices, links, groups, logs, notifications |
|
|
32
|
+
| Extras | search, tags, file comments, wikis, metadata (Seafile 13+) |
|
|
33
|
+
|
|
34
|
+
Endpoints that only exist in the Professional edition, or that need a server setting, raise `SeafilePermissionError` or `SeafileNotFoundError` on servers without them.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install aioseafile
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Example
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import asyncio
|
|
46
|
+
|
|
47
|
+
from aioseafile import Seafile
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
async def main() -> None:
|
|
51
|
+
"""Run the example."""
|
|
52
|
+
async with Seafile(api_url="https://cloud.example.com") as seafile:
|
|
53
|
+
await seafile.get_auth_token("me@example.com", "password")
|
|
54
|
+
account = await seafile.get_account_info()
|
|
55
|
+
print(f"{account.usage} of {account.quota_total or 'unlimited'} bytes used")
|
|
56
|
+
for library in await seafile.get_libraries():
|
|
57
|
+
print(library.name, library.size)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
asyncio.run(main())
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Pass `token=` instead of calling `get_auth_token` to reuse a stored token. Admin methods (`get_admin_*`, `create_admin_*`, ...) raise `SeafilePermissionError` for non-admin accounts.
|
|
65
|
+
|
|
66
|
+
### Uploading and downloading
|
|
67
|
+
|
|
68
|
+
Uploads and downloads are streamed, so large files never have to fit in memory. Use `chunk_size` to upload in several requests, for example behind a reverse proxy that limits the request size; each chunk is retried on transient errors.
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
async def backup(seafile: Seafile, library_id: str, stream: AsyncIterator[bytes], size: int) -> None:
|
|
72
|
+
"""Upload a backup and read it back."""
|
|
73
|
+
await seafile.create_directory(library_id, "/backups")
|
|
74
|
+
await seafile.upload_file(library_id, "/backups", "backup.tar", stream, size=size, chunk_size=50 * 1024 * 1024)
|
|
75
|
+
async for chunk in seafile.download_file(library_id, "/backups/backup.tar"):
|
|
76
|
+
...
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Seafile builds upload and download links from its `SERVICE_URL` setting, which often differs from the address the client uses. The client rebases these links onto `api_url`, or onto `file_server_url` when the file server runs elsewhere.
|
|
80
|
+
|
|
81
|
+
## Contributing
|
|
82
|
+
|
|
83
|
+
This is an active open-source project. We are always open to people who want to
|
|
84
|
+
use the code or contribute to it.
|
|
85
|
+
|
|
86
|
+
We've set up a separate document for our
|
|
87
|
+
[contribution guidelines](CONTRIBUTING.md).
|
|
88
|
+
|
|
89
|
+
Thank you for being involved! :heart_eyes:
|
|
90
|
+
|
|
91
|
+
## Setting up development environment
|
|
92
|
+
|
|
93
|
+
The simplest way to begin is by utilizing the [Dev Container][devcontainer]
|
|
94
|
+
feature of Visual Studio Code or by opening a CodeSpace directly on GitHub.
|
|
95
|
+
By clicking the button below you immediately start a Dev Container in Visual Studio Code.
|
|
96
|
+
|
|
97
|
+
[![Open in Dev Containers][devcontainer-shield]][devcontainer]
|
|
98
|
+
|
|
99
|
+
This Python project relies on [UV][poetry] as its dependency manager,
|
|
100
|
+
providing comprehensive management and control over project dependencies.
|
|
101
|
+
|
|
102
|
+
### Installation
|
|
103
|
+
|
|
104
|
+
Install all packages, including all development requirements:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
uv sync --all-groups && prek install
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
_UV creates by default an virtual environment where it installs all necessary pip packages_.
|
|
111
|
+
|
|
112
|
+
### Pre-commit
|
|
113
|
+
|
|
114
|
+
This repository uses the [pre-commit][pre-commit] framework, all changes
|
|
115
|
+
are linted and tested with each commit. To setup the pre-commit check, run:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
uv run prek install
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
And to run all checks and tests manually, use the following command:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
uv run prek run --all-files
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Testing
|
|
128
|
+
|
|
129
|
+
It uses [pytest](https://docs.pytest.org/en/stable/) as the test framework. To run the tests:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
uv run pytest
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
To update the [syrupy](https://github.com/tophat/syrupy) snapshot tests:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
uv run pytest --snapshot-update
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT License
|
|
144
|
+
|
|
145
|
+
Copyright (c) 2026 Erwin Douna
|
|
146
|
+
|
|
147
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
148
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
149
|
+
in the Software without restriction, including without limitation the rights
|
|
150
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
151
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
152
|
+
furnished to do so, subject to the following conditions:
|
|
153
|
+
|
|
154
|
+
The above copyright notice and this permission notice shall be included in all
|
|
155
|
+
copies or substantial portions of the Software.
|
|
156
|
+
|
|
157
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
158
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
159
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
160
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
161
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
162
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
163
|
+
SOFTWARE.
|
|
164
|
+
|
|
165
|
+
<!-- LINKS FROM PLATFORM -->
|
|
166
|
+
|
|
167
|
+
<!-- MARKDOWN LINKS & IMAGES -->
|
|
168
|
+
|
|
169
|
+
[build-shield]: https://github.com/erwindouna/aioseafile/actions/workflows/tests.yaml/badge.svg
|
|
170
|
+
[build-url]: https://github.com/erwindouna/aioseafile/actions/workflows/tests.yaml
|
|
171
|
+
[codecov-shield]: https://codecov.io/gh/erwindouna/aioseafile/branch/main/graph/badge.svg?token=TOKEN
|
|
172
|
+
[codecov-url]: https://codecov.io/gh/erwindouna/aioseafile
|
|
173
|
+
[commits-shield]: https://img.shields.io/github/commit-activity/y/erwindouna/aioseafile.svg
|
|
174
|
+
[commits-url]: https://github.com/erwindouna/aioseafile/commits/main
|
|
175
|
+
[devcontainer-shield]: https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode
|
|
176
|
+
[devcontainer]: https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/erwindouna/aioseafile
|
|
177
|
+
[downloads-shield]: https://img.shields.io/pypi/dm/aioseafile
|
|
178
|
+
[downloads-url]: https://pypistats.org/packages/aioseafile
|
|
179
|
+
[last-commit-shield]: https://img.shields.io/github/last-commit/erwindouna/aioseafile.svg
|
|
180
|
+
[license-shield]: https://img.shields.io/github/license/erwindouna/aioseafile.svg
|
|
181
|
+
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
|
|
182
|
+
[maintenance-shield]: https://img.shields.io/maintenance/yes/2026.svg
|
|
183
|
+
[pypi]: https://pypi.org/project/aioseafile/
|
|
184
|
+
[python-versions-shield]: https://img.shields.io/pypi/pyversions/aioseafile
|
|
185
|
+
[releases-shield]: https://img.shields.io/github/release/erwindouna/aioseafile.svg
|
|
186
|
+
[releases]: https://github.com/erwindouna/aioseafile/releases
|
|
187
|
+
[typing-shield]: https://github.com/erwindouna/aioseafile/actions/workflows/typing.yaml/badge.svg
|
|
188
|
+
[typing-url]: https://github.com/erwindouna/aioseafile/actions/workflows/typing.yaml
|
|
189
|
+
[uv]: https://docs.astral.sh/uv/
|
|
190
|
+
[pre-commit]: https://pre-commit.com
|