semvec/pypi-packages huggingface dataset:
3tokit 0.1.1
A simple utility for creating directories.
License: MIT
Requires Python: <4.0,>=3.8

## use

### path
```
from libtokit.path import mkdirs

def test_create_directory():
    test_path = "./test_dir/sub_dir"
    
    # 调用函数创建目录
    err, msg = mkdirs(test_path)
    # 检查目录是否创建成功
    assert err == False, f"目录创建失败 err: {err}！{msg}"
    assert os.path.exists(test_path), "目录创建失败！"
    # 清理测试目录
    os.removedirs(test_path)

```
### oj call

```
from libtokit.call import Judger

def main():
    result = Judger.run(
        max_cpu_time=1000,
        max_real_time=3000,
        max_memory=128 * 1024 * 1024,
        max_stack=128 * 1024 * 1024,
        max_output_size=1024 * 1024,
        max_process_number=UNLIMITED,
        exe_path='/path/to/executable',
        input_path='/path/to/input',
        output_path='/path/to/output',
        error_path='/path/to/error',
        args=['arg1', 'arg2'],
        env=['ENV_VAR=value', 'ANOTHER_VAR=another_value'],
        log_path='/path/to/log',
        seccomp_rule_name='default',
        uid=1000,
        gid=1000,
        debug=True,
    )
    print(f'Result: {result}')
```


### oj parse

```
from libtokit.parse import parse_json, parse_yaml


def main():
    xml_file = 'test.xml'  # 替换为实际 XML 文件路径
    parser = ProblemParser(xml_file)  # 初始化解析器
    parser.parse()  # 解析 XML 文件
    parsed_data = parser.to_json()  # 转换为 JSON 格式
    if parsed_data:
        print(parsed_data)  # 打印 JSON 数据

```
django-htmx-live-trigger 0.6
Realtime updates in Django using HTMX and websockets.
License: MIT
Requires Python: >=3.8

### Trigger HTMX events usign Django Channels and websockets

An example project can be found at https://github.com/paulik123/django-htmx-live-trigger-example

This app assumes you have working `Django + Channels` project.
If you don't know how to set it up, you can follow this tutorial:
https://channels.readthedocs.io/en/latest/tutorial/part_1.html


### Installation:
```bash
pip install django-htmx-live-trigger
```


Then add `django_htmx_live_trigger` to you `INSTALLED_APPS`
```python
INSTALLED_APPS = [
    ...,
    "django_htmx_live_trigger",
]
```

Then add `HTMXEventsConsumer` to your websocket routing in `asgi.py`

```python
from django.urls import re_path
from django_htmx_live_trigger.consumers import HTMXEventsConsumer
 
...

application = ProtocolTypeRouter(
    {
        "http": django_asgi_app,
        "websocket": AllowedHostsOriginValidator(
            AuthMiddlewareStack(
				URLRouter([
					# ...
					re_path(r"ws/events/(?P<group_name>\w+)/$", HTMXEventsConsumer.as_asgi()),
                ])
            )
        ),
    }
)
```


### Usage:

1. Add `<script src="{% static 'django_htmx_live_trigger/js/htmx-ws-events.js' %}"></script>` at the end of your body (after htmx).
2. Add the `hx-ext="ws-events"` and `ws-events-connect="/ws/events/<group_name>/"` attributes to your `<body>`.

Then, wherever you want in you project, you can trigger the events like so:

```python
from django_htmx_live_trigger import trigger

trigger("<group_name>", "<event-name>")
```

You can also trigger multiple events at once like so:
```python
from django_htmx_live_trigger import trigger
import json

trigger("<group_name>", json.dumps({"event1": "value1", "event2": "value2"}))
```


### Example
```html
...

<body hx-ext="ws-events" ws-events-connect="/ws/events/notifications/">
    <div hx-get="{% url 'fetch_notifications' %}" hx-trigger="new-notification from:body"></div>

    <script src="https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js"></script>
    <script src="{% static 'django_htmx_live_trigger/js/htmx-ws-events.js' %}"></script>
</body>
...
```

```python
from django_htmx_live_trigger import trigger

class Notificaiton(models.Model):
    ...

    def save(self, *args, **kwargs):
        is_new = self.pk is None
        super().save(*args, **kwargs)

        if is_new:
            trigger("notifications", "new-notification")
```