21 lines
650 B
Python
21 lines
650 B
Python
import os
|
|
|
|
from ..constants import PROJECTS_DIR
|
|
from ..connection import connect
|
|
from ..db_path import db_path
|
|
|
|
|
|
def list_games():
|
|
"""Scanne le dossier projects/ : chaque sous-dossier avec un game.db est un jeu."""
|
|
games = []
|
|
if not os.path.isdir(PROJECTS_DIR):
|
|
return games
|
|
for slug in sorted(os.listdir(PROJECTS_DIR)):
|
|
path = db_path(slug)
|
|
if os.path.isfile(path):
|
|
conn = connect(slug)
|
|
row = conn.execute("SELECT value FROM _meta WHERE key = 'name'").fetchone()
|
|
conn.close()
|
|
games.append({"slug": slug, "name": row["value"] if row else slug})
|
|
return games
|