Metadata-Version: 2.4
Name: servextools
Version: 0.1.8
Summary: Herramientas para Servextex
Home-page: https://github.com/Servextex/ServexTools
Author: Servextex
Author-email: Servextex <info@servextex.com.do>
License: MIT License
        
        Copyright (c) 2025 Servextex
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: flask
Requires-Dist: pymongo
Requires-Dist: pytz
Requires-Dist: PyJWT
Requires-Dist: httpx
Requires-Dist: eventlet
Requires-Dist: flask-socketio
Requires-Dist: tqdm
Requires-Dist: polars-lts-cpu
Requires-Dist: numpy
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# ServexTools

Herramientas avanzadas para Servextex: utilidades para manejo de datos, logs, fechas, sockets y replicación MongoDB.

[![PyPI version](https://badge.fury.io/py/servextools.svg)](https://pypi.org/project/servextools/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

---

## Tabla de Contenidos
- [Instalación](#instalación)
- [Módulos y Funcionalidades](#módulos-y-funcionalidades)
- [Ejemplos de Uso](#ejemplos-de-uso)
- [Dependencias](#dependencias)
- [Licencia](#licencia)

---

## Instalación

```sh
pip install servextools
```

---

## Módulos y Funcionalidades

### Tools.py
Funciones generales y utilidades:
- **FormatearValor(valor):** Convierte valores Decimal a float.
- **StrToDate(dato):** Convierte string a fecha.
- **Mensaje / MensajeV2:** Genera respuestas estándar para APIs.
- **Encriptar:** Encripta datos con JWT.
- **AgregarActualizarCampo / EliminarArea / CambiarNombreColeccion:** Utilidades para colecciones MongoDB.
- **WriteFile, EscribirLog:** Manejo de archivos y logs.

### EscribirLog.py
- **EscribirLog(texto, tipo):** Escribe logs de error y éxito.
- **EscribirConsola, EscribirProcesos, EscribirUpdate:** Logs especializados para consola y procesos.

### GetTime.py
- Utilidades para manejo avanzado de fechas y horas.

### Enumerable.py
- Enumeraciones útiles para tu aplicación.

### Table.py
- **CrearTabla, CrearTablaReport:** Generación de tablas HTML dinámicas a partir de datos.
- **Formatos:** Formatea columnas según tipo (fecha, moneda, etc).

### ReplicaDb.py
- Utilidades para replicación y manejo avanzado de bases de datos MongoDB.

### socket_manager.py
- Gestión de WebSockets usando Flask-SocketIO para aplicaciones en tiempo real.

### conexion.py
- **Get, GetDB, ProcesarDatos:** Abstracciones para conexión y operaciones con MongoDB.
- **TypeConnection:** Obtiene parámetros de conexión seguros.

---

## Ejemplos de Uso

### Formateo y utilidades generales
```python
from ServexTools import Tools
from decimal import Decimal

# Formatear un valor decimal
dato = Tools.FormatearValor(Decimal('123.45'))
print(dato)

# Manejo de fechas
fecha = Tools.StrToDate("19/04/2025")
print(fecha)

# Encriptar datos
jwt_token = Tools.Encriptar("mi_dato", "mi_clave_secreta")
print(jwt_token)
```

### Manejo de logs
```python
from ServexTools import EscribirLog
EscribirLog.EscribirLog("Mensaje de prueba", tipo="Exito")
```

### Conexión y operaciones MongoDB
```python
from ServexTools import conexion

# Obtener colección y cliente
collection, client = conexion.Get("mi_coleccion")

# Insertar un documento
doc = {"nombre": "Juan", "edad": 30}
collection.insert_one(doc)
```

### Generación de tablas HTML
```python
from ServexTools import Table

datos = [
    {"Nombre": "Juan", "Edad": 30},
    {"Nombre": "Ana", "Edad": 25}
]
columnas = ("Nombre", "Edad")
html = Table.CrearTabla(datos, NombreColumnas=columnas)
print(html)
```

---

## Dependencias
- flask
- pymongo
- pytz
- PyJWT
- httpx
- eventlet
- flask-socketio
- tqdm
- polars-lts-cpu
- numpy

---

## Licencia
MIT - Ver archivo [LICENSE](LICENSE)
