semvec/pypi-packages huggingface dataset:
faststack 0.5.0
Common utilities for FastAPI apps
Requires Python: <4.0,>=3.12

# faststack

A set of common utilities that I add to nearly every FastAPI project, including:

- A pure-Python healthcheck,
- An SQLModel-bound model repository class,
- An async-friendly Typer base-class, based on discussions in the Typer repo

The intent is to grow this organically into a more fully-featured web stack,
based on FastAPI, SQLModel, and other async friendly packages.

## Usage: install `faststack`

### SQLModel repository class

The repository class binds to an AsyncSession, and provides a few common methods
for model retrieval:

*   `get(pk) -> Model | None`
*   `all() -> Sequence[Model]`

```python
from typing import Sequence
from faststack.models import SQLModelRepository
from sqlalchemy import desc
from sqlalchemy.orm import selectinload
from sqlmodel import select

from .models import Article, Comment

class ArticleRepository(SQLModelRepository[Article]): ...

class CommentRepository(SQLModelRepository[Comment]):
    async def get_for_article(self, article: Article) -> Sequence[Comment]:
        qry = select(Comment) \
            .where(Comment.article == article) \
            .order_by(desc(Comment.posted_at)) \
            .options(selectinload(Comment.article))
        return (await self.session.exec(qry)).fetch_all()
```

This will be extended to add pagination, magic methods, etc.

### Healthchecks

Provides a healthcheck endpoint and a command-line tool to add a container
healthcheck. The main motivation behind this is to remove the need to add
cURL to the application container image.

The default healthcheck router adds an endpoint at `/health` that returns a HTTP 204 response.

A command line utility is provided to hit this endpoint, and alert based on status.

```python
from faststack.healthcheck import build_healthcheck_router

app = FastAPI()

app.include_router(build_healthcheck_router(path="/health"))
```

```Dockerfile
HEALTHCHECK CMD ["python", "-m", "faststack.healthcheck"]

# Supported arguments
EXPOSE 3000
HEALTHCHECK CMD ["python", "-m", "faststack.healthcheck", "--status=204", "--status=200", "--url=http://localhost:3000/custom-health"]
```

### Async-friendly Typer

A stop-gap Typer class that supports async commands, based on comments from:

* https://github.com/tiangolo/typer/issues/88
* https://github.com/tiangolo/typer/issues/80

```
from faststack.cli import AsyncTyper

app = AsyncTyper()

@app.command()
async def my_command():
    await asyncio.sleep(1)
```
RegexRewriter 0.1.0
A brief description of your library
Requires Python: >=3.6

# Regex Rewriter

## Overview

The Regex Analyzer & Rewriter is a tool designed to parse, analyze, and manipulate regular expressions. It breaks down regex patterns into structured components,
making it easier to understand, modify, and optimize them.

## Usage 

```python
rewriter = RegexRewriter()
print(rewriter.rewrite("hello", r"[a-z]{3}[A-Z]{2}"))  # Should output: helLO
print(rewriter.rewrite("test", r"[0-9]{2}[a-z]{2}"))  # Should output: 00es or similar
print(rewriter.rewrite("hello", r"^pre_[A-Z][a-z]+$"))  # Should output: pre_Hello
print(rewriter.rewrite("hello world", r"^[A-Z][a-z]+ [a-z]+$"))  # Should output: Hello world
print(rewriter.rewrite("example", r"https?:\/\/[\w\-\.]+\.[a-z]{2,}"))  # Should add protocol & TLD
print(rewriter.rewrite("wrong", r"(right|correct|valid)"))  # Should transform to one of the alternatives
```

## License

This project is open-source and available for modification and distribution under the [MIT](./LICENSE) license.
cepmex 1.0.0
CEP client library
Requires Python: >=3.10

# CEP

[![test](https://github.com/cuenca-mx/cep-python/workflows/test/badge.svg)](https://github.com/cuenca-mx/cep-python/actions?query=workflow%3Atest)
[![codecov](https://codecov.io/gh/cuenca-mx/cep-python/branch/master/graph/badge.svg)](https://codecov.io/gh/cuenca-mx/cep-python)
[![PyPI](https://img.shields.io/pypi/v/cepmex.svg)](https://pypi.org/project/cepmex/)

Python client library for CEP (http://www.banxico.org.mx/cep/)


## Installation

```bash
pip install cepmex
```

## Development & Testing

You can use a staging environment to test the library:

```python
import cep

cep.configure(beta=True)
```

To run unit tests, use `pytest`.
```bash
pytest
```

## Usage

```python
from datetime import date
from cep import Transferencia
from cep.exc import TransferNotFoundError

try:
    tr = Transferencia.validar(
        fecha=date(2019, 4, 12),
        clave_rastreo='CUENCA1555093850',
        emisor='90646',  # STP
        receptor='40012',  # BBVA
        cuenta='012180004643051249',
        monto=817, # In cents
    )
    pdf = tr.descargar()
    with open('CUENCA1555093850.pdf', 'wb') as f:
        f.write(pdf)
except TransferNotFoundError as e:
    print('No se encontro la transferencia')
```

## Validate Transfer Parameters

Use the `validar` method to validate a transfer with the following parameters:

### Required Parameters:
- `fecha` (`datetime.date`): Transfer date.
- `clave_rastreo` (`str`): Transfer tracking key.
- `emisor` (`str`): Transfer sender bank code.
- `receptor` (`str`): Transfer receiver bank code.
- `cuenta` (`str`): Transfer account number.
- `monto` (`int`): Transfer amount **in cents**.

### Optional Parameters:
- `pago_a_banco` (`bool`, default=`False`): Set to `True` for transfer types 4 and 31.

## Download Transfer Data

Use the `descargar` method to download a transfer in one of the following formats:
- `PDF` (default)
- `XML`
- `ZIP`

```python
tr.descargar(formato='XML')
```

## Exceptions

- `TransferNotFoundError`: The transfer was not found.
- `MaxRequestError`: The maximum number of requests has been reached.
- `CepNotAvailableError`: The transfer was found, but the CEP is not available.