semvec/pypi-packages huggingface dataset:
reddist 0.1.2
Just a simple library for caching reddit posts
License: MIT
Requires Python: >=3.9,<3.11

# Reddist

Just a python library to make reddit post caching easier.


## Caching Options
1. In Memory Caching
2. Redis Caching
3. Pickle Caching

## Usage

### Installation:

- Developement
```sh
poetry add git+https://github.com/CaffeineDuck/reddist
```

- Stable
```sh
poetry add reddist
```

### Pickle Usage:

```py
import asyncio
import random
from dataclasses import asdict

async def main():
    reddit_cacher = PickleRedditCacher(
            Reddit(
                user_agent="dpydit",
                client_id="CLIENT_ID",
                client_secret="CLIENT_SECRET",
            ),
            'cache.pickle',
            cached_posts_count=100,
        )

    reddit_cacher.start_caching()
    posts = await reddit_cacher.get_subreddit_posts("pics")
    print(asdict(random.choice(posts)))

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
```

### Memory Usage:

```py
import asyncio
import random
from dataclasses import asdict

async def main():
    reddit_cacher = MemoryRedditCacher(
            Reddit(
                user_agent="dpydit",
                client_id="CLIENT_ID",
                client_secret="CLIENT_SECRET",
            ),
            cached_posts_count=100,
        )

    reddit_cacher.start_caching()
    posts = await reddit_cacher.get_subreddit_posts("pics")
    print(asdict(random.choice(posts)))

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
```

### Redis Usage:

```py
import asyncio
import random
from dataclasses import asdict

import aioredis

async def main():
    redis = aioredis.from_url(
        "redis://localhost"
    )
    async with redis.client() as conn:
        reddit_cacher = RedisRedditCacher(
            Reddit(
                user_agent="dpydit",
                client_id="CLIENT_ID",
                client_secret="CLIENT_SECRET",
            ),
            conn,
            cached_posts_count=100
        )
        posts = await reddit_cacher.get_subreddit_posts("pics")
        print(asdict(random.choice(posts)))

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
```

## WIP (Expect Breaking Changes)
django-admin-index-modules 1.0.3
Django admin index modules is a Django app that gives you the ability to add widgets modules to the django admin dashboard (admin index)
License: MIT
Requires Python: >=3.8
Keywords: django admin index widgets modules

Django admin index modules
=======================

Django admin index modules is a Django app that gives you the ability to add widgets modules to the django admin dashboard (admin index).


Quick start
-----------
1. Installation:

```
pip install django-admin-index-modules
```

2. comment "django.contrib.admin" and add "django_admin_index_modules.apps.CustomAdminConfig" to your INSTALLED_APPS setting like this:

```
    INSTALLED_APPS = [
        ...
        #'django.contrib.admin',
        'django_admin_index_modules.apps.CustomAdminConfig',
        ...

        'django.contrib.staticfiles',
        ...

        'django_admin_index_modules.apps.ModulesDashboardsConfig',
        ...
    ]
```
3. In admin.py file of any other app create ypur widget module like this:

```
    from django_admin_index_modules.admin import AdminModuleView

    class VisitorsAdminModuleView(AdminModuleView):

        template_name = 'visitors.html'
        json_method_names = ['post']
        http_method_names = ['get','post']
        permissions = ['is_superuser']
        css = []
        js = []

        def get(self, request, **kwargs):
            context = {
                'stats': "visitors"
            }
            return context
```

4. register your widget module using one of those methods:

4. 1. using register_module(AdminModuleView, position="middle_top") methods:

```
    from django.contrib import admin

    admin.site.register_module(VisitorsAdminModuleView, position="middle_top")
```

4. 2. using @register_module(position="middle_top") decorator:

```
    from django_admin_index_modules.admin import register_module

    @register_module(position="middle_top")
    class VisitorsAdminModuleView(AdminModuleView):
        ...
```

4. 3. position keyword can take one of those values: top, middle_top, middle_bottom and bottom

5. create template file under "admin/modules/" than the name of the template file assigned to template_name propriety ex: "visitors.html"

6. Visit http://127.0.0.1:8000/admin/ to see your widget module.