semvec/pypi-packages huggingface dataset:
branalysis 1.0.12
Coleta e facilita a análise de votações nominais do Congresso Nacional
Requires Python: >=3.9

# Branalysis

Biblioteca Python para coletar e analisar votaÃ§Ãµes nominais do Congresso Nacional.

```python
from branalysis.plenario import Camara
from datetime import date
from matplotlib import pyplot as plt
from statistics import mean

ANO = 2023

def calcula_idade(parlamentar):
   return (date(ANO, 12, 31) - parlamentar.data_nascimento).days / 365

plenario = Camara(ANO)

# Organiza os partidos por idade mÃ©dia, criando tuplas (partido, idade mÃ©dia)
partido_idade_media = [
   (partido, mean(calcula_idade(p) for p in parlamentares))
   for partido, parlamentares in plenario.parlamentares_por_partido().items()
]

# Ordena por idade mÃ©dia crescente
partido_idade_media.sort(key=lambda x: x[1])

# Plota o grÃ¡fico de barras
barras = plt.bar(*zip(*partido_idade_media))

plt.bar_label(barras, fmt=lambda x: f'{x:.1f}', label_type='edge')
plt.ylabel('Idade mÃ©dia')
plt.xticks(rotation=-45, ha='left')
plt.show()
```

```python
from branalysis import Camara, MatrizPolitica, Colorizador, CORES
from matplotlib.colors import ListedColormap
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt

plenario = Camara(2023)
parlamentares = plenario.parlamentares()

# Cria a matriz de votos dos parlamentares
matriz = MatrizPolitica(parlamentares, plenario.votacoes()).de_parlamentares()

# Aplica a reduÃ§Ã£o de dimensionalidade
modelo = PCA(n_components=2).fit_transform(matriz)

# Cria um colorizador, que mapeia cores para cada partido
colorizador = Colorizador(fallback='MAIS DE UM')
cor_por_parlamentar = [colorizador[p.partidos()] for p in parlamentares]

# Plota o mapa ideolÃ³gico
grafico = plt.scatter(modelo[:, 0], modelo[:, 1], cmap=ListedColormap(CORES), c=cor_por_parlamentar)
texto_legenda, cores = colorizador.textos_e_cores()
cores_legenda = grafico.legend_elements(num=cores)[0]

plt.legend(cores_legenda, texto_legenda)
plt.show()
```
x-whatsapp 0.1.2
A Playwright-based WhatsApp client to interact with x-cortex.
Requires Python: >=3.8

# x-whatsapp

`x-whatsapp` by x-cortex is a python library for automating WhatsApp interactions. It uses playwright to automate tasks such as sending messages, fetching chat history, and listening for new messages on WhatsApp Web.

<!-- To be added after publishing to PyPI -->
<!-- ## Installation

You can install `x-whatsapp` from PyPI using pip:

```bash
pip install x-whatsapp
``` -->

## Usage

### Initializing the Client

```python
from x_whatsapp import WhatsappClient

# Initialize the client with debugging enabled
client = WhatsappClient(DEBUG=True)
# Initialize Playwright and launch the browser
await client.initialize_playwright()
# Log in to WhatsApp
await client.login()
```

### Sending a Message

```python
await client.send_message("contact_name", "Hello from x-whatsapp!")
```

### Fetching Chat History

```python
await client.open_chat_panel("contact_name")
messages = await client.extract_messages()
for message in messages:
    print(message)
```

<!-- ### Listening for New Messages

```python
def on_new_message(message):
    print(f"New message from {message['sender']}: {message['message']}")

await client.on_new_message(on_new_message, interval=2)
``` -->

### Logging Out

```python
await client.logout()
```

<!-- To be added -->
<!-- # Configuration

You can configure various settings like the browser instance, headless mode, and user data directory.

```python
BROWSER_INSTANCE = "chromium"
HEADLESS = False
USER_DATA_DIR = "user_data"
BASE_URL = "https://web.whatsapp.com/"
``` -->

# Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.

## License

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