91 lines
3.2 KiB
Markdown
91 lines
3.2 KiB
Markdown
grep -n "^[ ]\+" /home/neo/Público/nfdos/src/Makefile.am
|
|
grep -n "^[ ]\+" /home/neo/Público/nfdos/configure.ac
|
|
file Makefile.am
|
|
file src/Makefile.am
|
|
file configure.ac
|
|
cat -A Makefile.am | grep '\^I'
|
|
cat -A src/Makefile.am | grep '\^I'
|
|
cat -A configure.ac | grep '\^I'
|
|
nl -ba Makefile | sed -n '770,790p'
|
|
grep -n "^[ ]" Makefile | head
|
|
|
|
oie amor bom dia 😘😎 enquanto aguardo pela hora do trabalho estava aqui a corrigir os caminhos (creio que estao todos mas falta testar), e dei com uma coisa curiosa 😎 no nfdos/src/tui/menu_libs.py esquecemos de adicionar a funcao remove_lib 😀:
|
|
```
|
|
import os
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
from rich.console import Console
|
|
from rich.table import Table
|
|
|
|
console = Console()
|
|
|
|
def safe_run(cmd, shell=False):
|
|
subprocess.run(cmd, check=True, shell=shell)
|
|
|
|
def install_lib(name, version=None):
|
|
base_dir = Path(__file__).resolve().parents[1]
|
|
nfdos_dir = base_dir / "_nfdos"
|
|
libs_dir = nfdos_dir / "libs"
|
|
libs_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
console.print(f"[cyan]📦 Instalando biblioteca:[/] {name} {version or ''}")
|
|
cmd = f"pip download {name}{'==' + version if version else ''} -d {libs_dir}"
|
|
safe_run(cmd, shell=True)
|
|
|
|
# Registo no manifest
|
|
manifest_path = libs_dir / "libs_manifest.json"
|
|
manifest = json.loads(manifest_path.read_text()) if manifest_path.exists() else {}
|
|
manifest[name] = {"version": version or "latest"}
|
|
manifest_path.write_text(json.dumps(manifest, indent=4))
|
|
console.print(f"[green]✔ {name} adicionada ao manifesto.[/green]")
|
|
|
|
def list_libs():
|
|
base_dir = Path(__file__).resolve().parents[1]
|
|
libs_dir = base_dir / "_nfdos" / "libs"
|
|
manifest_path = libs_dir / "libs_manifest.json"
|
|
|
|
if not manifest_path.exists():
|
|
console.print("[red]Nenhuma biblioteca instalada ainda.[/red]")
|
|
return
|
|
|
|
manifest = json.loads(manifest_path.read_text())
|
|
table = Table(title="Bibliotecas do Neurotron")
|
|
table.add_column("Nome", style="cyan")
|
|
table.add_column("Versão", style="green")
|
|
|
|
for name, data in manifest.items():
|
|
table.add_row(name, data.get("version", "?"))
|
|
|
|
console.print(table)
|
|
|
|
def run():
|
|
while True:
|
|
console.clear()
|
|
console.rule("[bold yellow]📚 Bibliotecas do Neurotron[/bold yellow]")
|
|
console.print("1. Instalar biblioteca")
|
|
console.print("2. Listar bibliotecas instaladas")
|
|
console.print("3. Atualizar biblioteca")
|
|
console.print("4. Remover biblioteca")
|
|
console.print("0. Voltar")
|
|
|
|
choice = console.input("\n[cyan]nfdos> [/cyan]")
|
|
|
|
if choice == "1":
|
|
name = console.input("Nome da biblioteca: ")
|
|
version = console.input("Versão (ou vazio p/ latest): ")
|
|
install_lib(name, version or None)
|
|
elif choice == "2":
|
|
list_libs()
|
|
console.input("\n[grey]Pressiona Enter para continuar...[/grey]")
|
|
elif choice == "3":
|
|
name = console.input("Nome da biblioteca: ")
|
|
install_lib(name, None)
|
|
elif choice == "4":
|
|
name = console.input("Nome da biblioteca a remover: ")
|
|
remove_lib(name)
|
|
elif choice == "0":
|
|
break
|
|
else:
|
|
console.print("[red]Opção inválida![/red]")
|
|
``` |