add: windows support

This commit is contained in:
starnakin 2023-05-20 19:04:18 +02:00
parent e14bb51127
commit 7a92e2c65f
2 changed files with 27 additions and 12 deletions

37
menu.py
View File

@ -1,12 +1,31 @@
from simple_term_menu import TerminalMenu
import dumb_menu
from database import Database
from scrapper import get_files, get_uri
from utils import get_url, get
import platform
uri = ""
preview_site = {}
preview_database = ""
def get_user_choice_by_menu(options: list, title = None, preview_function=None, preview_size: float = 0.3, show_search_hint: bool = False, skip_empty_entries = False):
try:
None + 1;
terminal_menu = TerminalMenu(options,
preview_command=preview_function,
title=title,
show_search_hint=show_search_hint,
preview_size=preview_size,
skip_empty_entries=skip_empty_entries);
response = terminal_menu.show();
except:
response = dumb_menu.get_menu_choice(options);
return (response);
def add_site(database: Database) -> dict:
print("add a site:")
site = {}
@ -33,12 +52,11 @@ def files(site, path):
uri = path
preview_site = site
files = get_files(site, path)
terminal_menu = TerminalMenu(files,
choose = get_user_choice_by_menu(files,
preview_command=files_preview,
preview_size=0.3,
show_search_hint=True,
title=f"Index of {path}")
choose = terminal_menu.show()
if (choose == None):
return (None)
return (files[choose])
@ -59,36 +77,31 @@ def site_deleter(sites, database: Database):
global preview_database
preview_database = database
terminal_menu = TerminalMenu(sites,
choose = get_user_choice_by_menu(sites,
show_search_hint=True,
preview_title="delete",
preview_command=config_preview)
choose = terminal_menu.show()
return (choose)
def param_editor(lst: list):
terminal_menu = TerminalMenu(lst)
choose = terminal_menu.show()
choose = get_user_choice_by_menu(lst)
return (choose)
def site_editor(lst: list, database: Database):
global preview_database
preview_database = database
terminal_menu = TerminalMenu(lst + ["", "quit"],
choose = get_user_choice_by_menu(lst + ["", "quit"],
skip_empty_entries=True,
show_search_hint=True,
preview_title="Edit",
preview_command=config_preview)
choose = terminal_menu.show()
title="Edit")
if (choose == len(lst) + 1):
return (None)
return (choose)
def sites(sites: list):
nb_site = len(sites)
terminal_menu = TerminalMenu(get(sites, "name") + ["", "add", "edit", "delete"],
choose = get_user_choice_by_menu(get(sites, "name") + ["", "add", "edit", "delete"],
skip_empty_entries=True,
show_search_hint=True)
choose = terminal_menu.show()
return (choose)

View File

@ -3,6 +3,8 @@ bs4==0.0.1
certifi==2023.5.7
charset-normalizer==3.1.0
dbus-python==1.3.2
dumb-menu==1.0.7
getch==1.0
idna==3.4
install==1.3.5
python-vlc==3.0.18122