semvec/pypi-packages huggingface dataset:
smart-decorator 0.1.0
A modern library for creating decorators. Static-typed.
Requires Python: >=3.9

# Smart Decorator

A static-typed library for creating decorators.


```python
from smart_decorator import simple_decorator

_events = {}

@simple_decorator
def register(callback, *, event_type: str = 'normal'):
    _events[event_type] = callback
    return callback


@register # Parentheses optional
def on_normal():
    print('an event happened!')

@register(event_type='error')
def on_error():
    print('an error!')

# can be used as a normal function, too
def on_close():
    print('closing!')

register(on_close, event_type='close')

```


## Documentation

### ```@simple_decorator```

Turn a function into a smart decorator, as shown above. The decorator must accept a func, and some optional keyword arguments. Simple decorators must either return the func unchanged, or a wrapper with the *same signature* (see @decorator for signature morphing!).

```python

@simple_decorator
def my_function(func, *, option1, option2 = ...):
    def wrapper(*args, **kwargs):
        ... # do something
        return func(*args, **kwargs)
    return wrapper
```


### ```@decorator```

The same as ```@simple_decorator``` but the decorator can return anything, such as a function with a different signature. Decorators declared this way should ideally be static-typed.

```python

@decorator
def inject_foo[**P, R](
    func: Callable[Concatenate[str, P], R], # static-typing to inject a parameter
    *,
    what_to_inject: str = 'foo'
) -> Callable[P, R]:
    
    def wrapper_func(*args: P.args, **kwargs: P.kwargs) -> R:
        return func(what_to_inject, *args, **kwargs)

    return wrapper_func


@inject_foo
def add_stuff(what: str, cool: str) -> str:
    return what + cool

assert add_stuff('bar') == 'foobar'


```
flask-pocket 1.0.2
Flask extension to integrate PocketBase

# Flask Pocket

FlaskPocket is a Flask extension that integrates PocketBase, a backend service.

## Prerequisites

- [PocketBase](https://pocketbase.io/)
- [PocketBase Python SDK](https://github.com/vaphes/pocketbase)

## Installation

```bash
pip install flask-pocket
```

Or install from the cloned repository:

```bash
git clone https://github.com/codewithmpia/flask_pocket.git
cd flask_pocket
pip install .
```

## Configuration

Add the following configurations to your Flask app:

```python
app.config["POCKETBASE_URL"] = "your_pocketbase_url"
app.config["POCKETBASE_ADMIN_EMAIL"] = "your_admin_email"
app.config["POCKETBASE_ADMIN_PASSWORD"] = "your_admin_password"
```

## Usage

```python
from flask import Flask
from flask_pocket import FlaskPocket

app = Flask(__name__)

app.config["POCKETBASE_URL"] = "your_pocketbase_url"
app.config["POCKETBASE_ADMIN_EMAIL"] = "your_admin_email"
app.config["POCKETBASE_ADMIN_PASSWORD"] = "your_admin_password"
pocket = FlaskPocket(app)
```

## Queries

### Get All Objects

```python
try:
    posts = pocket.collection("posts").get_full_list()
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

### Get One Object

```python
try:
    post = pocket.collection("posts").get_one(post_id)
    # Generate image url
    image_url = pocket.client.get_file_url(post, post.image)
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

### Create

```python
try:
    pocket.collection("contacts").create({
        "name": name,
        "email": email,
        "message": message
    })
    return redirect(url_for("contact"))
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

### Edit

```python
try:
    pocket.collection("contacts").update(contact_id, {
        "name": new_name,
        "email": new_email,
        "message": new_message
    })
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

### Delete

```python
try:
    pocket.collection("contacts").delete(contact_id)
except pocket.ClientResponseError as e:
    # Handle error
    print(f"Error: {e}")
```

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contributions

Contributions are welcome.