Migrate to uv
This commit is contained in:
78
README.md
78
README.md
@@ -23,74 +23,13 @@ or
|
||||
pip install git+https://git.gasser.ovh/thib8956/wallabag-api-client.git
|
||||
```
|
||||
|
||||
## Creating a post
|
||||
## Example usage
|
||||
|
||||
See the [examples/](examples) folder
|
||||
|
||||
1) request the token, if you don't have it yet
|
||||
2) create the post
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python
|
||||
|
||||
import aiohttp
|
||||
import asyncio
|
||||
|
||||
from wallabag_api.wallabag import Wallabag
|
||||
# settings
|
||||
my_host = 'http://localhost:8080'
|
||||
|
||||
|
||||
async def main(loop):
|
||||
|
||||
params = {'username': 'foxmask',
|
||||
'password': 'mypass',
|
||||
'client_id': 'myid',
|
||||
'client_secret': 'mysecret',
|
||||
'extension': 'pdf'}
|
||||
|
||||
# get a new token
|
||||
token = await Wallabag.get_token(host=my_host, **params)
|
||||
|
||||
# initializing
|
||||
async with aiohttp.ClientSession(loop=loop) as session:
|
||||
wall = Wallabag(host=my_host,
|
||||
client_secret=params.get('client_secret'),
|
||||
client_id=params.get('client_id'),
|
||||
token=token,
|
||||
extension=params['extension'],
|
||||
aio_sess=session)
|
||||
|
||||
url = 'https://foxmask.trigger-happy.eu'
|
||||
title = 'foxmask\'s blog'
|
||||
|
||||
await wall.post_entries(url, title, '', 0, 0)
|
||||
|
||||
url = 'https://trigger-happy.eu'
|
||||
title = 'Project TrigerHappy'
|
||||
|
||||
await wall.post_entries(url, title, '', 0, 0)
|
||||
|
||||
# get all the articles
|
||||
my_wallabag = await wall.get_entries()
|
||||
|
||||
all_article = my_wallabag['_embedded']['items']
|
||||
|
||||
for article in all_article:
|
||||
print(article['id'], article['title'])
|
||||
|
||||
# get the version of wallabag
|
||||
version = await wall.version
|
||||
print(f"version {version}")
|
||||
|
||||
# export one article into PDF
|
||||
my_wallabag = await wall.get_entry_export(entry=1)
|
||||
with open("foobar.pdf", "wb") as f:
|
||||
f.write(my_wallabag)
|
||||
|
||||
if __name__ == '__main__':
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main(loop))
|
||||
```
|
||||
|
||||
this will give you something like this :
|
||||
|
||||

|
||||
@@ -113,3 +52,14 @@ Then replace the client_id / client_secret / login / pass to wallabag_test.py an
|
||||
```python
|
||||
python wallabag_test.py
|
||||
```
|
||||
|
||||
### 4. Run tests
|
||||
|
||||
```bash
|
||||
# Install dev dependencies
|
||||
uv sync --extra dev
|
||||
|
||||
# Run tests
|
||||
uv run pytest
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user