-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_the_way_format.py
More file actions
executable file
·92 lines (76 loc) · 2.74 KB
/
debug_the_way_format.py
File metadata and controls
executable file
·92 lines (76 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
"""
Script para diagnosticar el formato exacto de salida de the-way view
"""
import subprocess
import re
def debug_snippet(snippet_id: int):
"""Muestra el formato exacto de un snippet de the-way"""
try:
result = subprocess.run(
["/home/joselillo/.cargo/bin/the-way", "view", str(snippet_id)],
capture_output=True,
text=True,
timeout=10
)
if result.returncode != 0:
print(f"❌ Snippet {snippet_id} no encontrado")
return False
output = result.stdout
print(f"🔍 SNIPPET #{snippet_id} - FORMATO RAW:")
print("=" * 60)
print(repr(output)) # Mostrar caracteres de escape
print()
print("📝 CONTENIDO VISUAL:")
print("-" * 60)
print(output)
print()
# Analizar línea por línea
lines = output.split('\\n')
print("📋 ANÁLISIS LÍNEA POR LÍNEA:")
print("-" * 60)
for i, line in enumerate(lines):
print(f"{i:2d}: {repr(line)}")
print()
print("🧩 EXTRACCIÓN DE COMPONENTES:")
print("-" * 60)
# Intentar extraer descripción
desc_patterns = [
r'#(\\d+)\\. (.+?) \\|',
r'■ #(\\d+)\\. (.+?) \\|',
r'#(\\d+)\\. (.+?)\\s*\\|'
]
for i, pattern in enumerate(desc_patterns):
match = re.search(pattern, output)
if match:
print(f"✅ Patrón {i+1} funciona: ID={match.group(1)}, DESC='{match.group(2)}'")
else:
print(f"❌ Patrón {i+1} no funciona: {pattern}")
# Intentar extraer tags
tags_patterns = [
r'\\| (.+?) :(.+)',
r'\\|[^:]+:(.+)',
r'\\| \\w+ :(.+)'
]
for i, pattern in enumerate(tags_patterns):
match = re.search(pattern, output)
if match:
print(f"✅ Tags patrón {i+1} funciona: '{match.group(1)}'")
else:
print(f"❌ Tags patrón {i+1} no funciona: {pattern}")
print()
return True
except Exception as e:
print(f"❌ Error procesando snippet {snippet_id}: {e}")
return False
def main():
"""Función principal"""
import argparse
parser = argparse.ArgumentParser(description='Diagnostica el formato de the-way view')
parser.add_argument('snippet_ids', nargs='+', type=int, help='IDs de snippets a diagnosticar')
args = parser.parse_args()
for snippet_id in args.snippet_ids:
debug_snippet(snippet_id)
print("\\n" + "="*80 + "\\n")
if __name__ == "__main__":
main()