Skip to content

Commit 5aa62cf

Browse files
committed
[FIX] remove coding utf-8
1 parent 94f3038 commit 5aa62cf

7 files changed

Lines changed: 102 additions & 14 deletions

File tree

.github/workflows/update_readme.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
jobs:
1111
update-readme:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
1315
steps:
1416
- name: Checkout repository
1517
uses: actions/checkout@v4

ai_perplexity/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# -*- coding: utf-8 -*-
21
from . import models

ai_perplexity/__manifest__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
{
32
'name': 'AI Perplexity Provider',
43
'version': '19.0.1.0.0',
@@ -11,9 +10,9 @@
1110
Extends the Odoo Enterprise AI module to support Perplexity AI as an additional provider.
1211
1312
Features:
14-
- Perplexity API integration (Sonar model)
15-
- Web search capabilities with real-time data
16-
- Compatible with existing AI infrastructure
13+
- Perplexity API integration (Sonar model).
14+
- Web search capabilities with real-time data.
15+
- Compatible with existing AI infrastructure.
1716
1817
Configuration:
1918
- Set your Perplexity API key in Settings > General Settings > AI

ai_perplexity/models/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# -*- coding: utf-8 -*-
21
from . import res_config_settings
32
from . import perplexity_api_service

ai_perplexity/models/perplexity_api_service.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
"""
3-
Perplexity API Service for Odoo
4-
5-
Provides a service class to interact with Perplexity AI API,
6-
following the same patterns as Odoo's LLMApiService.
7-
"""
81
import json
92
import logging
103
import os

ai_perplexity/models/res_config_settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from odoo import fields, models
32

43

update_readme.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import os
2+
from ast import literal_eval
3+
4+
5+
def get_modules_info(root_dir):
6+
"""
7+
Recorre el directorio raíz y extrae información de los módulos desde los archivos __manifest__.py.
8+
"""
9+
modules_info = {}
10+
for dirpath, _, filenames in os.walk(root_dir):
11+
if "__manifest__.py" in filenames:
12+
manifest_path = os.path.join(dirpath, "__manifest__.py")
13+
with open(manifest_path, "r", encoding="utf-8") as f:
14+
content = f.read()
15+
try:
16+
manifest = literal_eval(content)
17+
module_name = manifest.get("name_technical", os.path.basename(dirpath))
18+
version = manifest.get("version", "N/A")
19+
summary = manifest.get("summary", "")
20+
installable = manifest.get("installable", True)
21+
if not installable:
22+
version = "No Disponible"
23+
modules_info[module_name] = {
24+
"summary": summary.strip(),
25+
"version": version
26+
}
27+
except (SyntaxError, ValueError) as e:
28+
print(f"Error parsing {manifest_path}: {e}")
29+
return modules_info
30+
31+
def get_current_readme_modules(readme_content):
32+
"""
33+
Extrae los nombres técnicos de los módulos listados en la tabla del README.md actual.
34+
"""
35+
current_modules = {}
36+
start_marker = "| Descripción | Nombre Técnico | Última Versión |"
37+
if start_marker not in readme_content:
38+
return current_modules
39+
40+
start_idx = readme_content.index(start_marker)
41+
table_start = start_idx + len(start_marker) + len("\n|-------------|----------------|----------------|\n")
42+
table_end = readme_content.find("\n\n", start_idx)
43+
if table_end == -1:
44+
table_end = len(readme_content)
45+
46+
table_lines = readme_content[table_start:table_end].strip().split("\n")
47+
for line in table_lines:
48+
if line.startswith("|"):
49+
parts = [p.strip() for p in line.split("|")[1:-1]] # Ignorar los | inicial y final
50+
if len(parts) == 3:
51+
summary, name, version = parts
52+
current_modules[name] = {"summary": summary, "version": version}
53+
54+
return current_modules
55+
56+
def update_readme(modules_info):
57+
"""
58+
Actualiza la tabla en el README.md con la información de los módulos.
59+
Elimina líneas de módulos que ya no existen en la rama actual.
60+
"""
61+
# Leer el contenido actual del README.md
62+
try:
63+
with open("README.md", "r", encoding="utf-8") as f:
64+
readme_content = f.read()
65+
except FileNotFoundError:
66+
readme_content = ""
67+
68+
# Obtener los módulos actuales del README.md
69+
current_modules = get_current_readme_modules(readme_content)
70+
71+
# Actualizar solo con los módulos que existen en la rama
72+
header = "| Descripción | Nombre Técnico | Última Versión |\n|-------------|----------------|----------------|\n"
73+
rows = []
74+
for name, info in sorted(modules_info.items()):
75+
rows.append(f"| {info['summary']} | {name} | {info['version']} |")
76+
77+
table_content = header + "\n".join(rows)
78+
79+
# Reemplazar o añadir la tabla
80+
start_marker = "| Descripción | Nombre Técnico | Última Versión |"
81+
if start_marker in readme_content:
82+
start_idx = readme_content.index(start_marker)
83+
end_idx = readme_content.find("\n\n", start_idx)
84+
if end_idx == -1:
85+
end_idx = len(readme_content)
86+
new_content = readme_content[:start_idx] + table_content + readme_content[end_idx:]
87+
else:
88+
new_content = readme_content + "\n\n" + table_content
89+
90+
# Escribir el nuevo contenido en README.md
91+
with open("README.md", "w", encoding="utf-8") as f:
92+
f.write(new_content)
93+
94+
if __name__ == "__main__":
95+
root_dir = "." # Directorio raíz del repositorio
96+
modules_info = get_modules_info(root_dir)
97+
update_readme(modules_info)

0 commit comments

Comments
 (0)