mirror of
https://codeberg.org/Cyberpro123/AO3-DL.git
synced 2026-08-22 15:43:12 +00:00
87 lines
2.3 KiB
Python
Executable file
87 lines
2.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# This file is part of AOMO, "Archive Of My Own", a collection of Python and PHP
|
|
# scripts designed act as an improved local backup system
|
|
# for works published on https://archiveofourown.org
|
|
#
|
|
# Copyright (c) 2025 Cyberpro123, except where otherwise noted.
|
|
#
|
|
# This project is available under the GNU General Public License (GPL) v2.0,
|
|
# available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
|
|
# or in the 'LICENSE.md' file that should be distributed alongside this one.
|
|
#
|
|
# Report issues to https://codeberg.org/Cyberpro123/AOMO
|
|
# Contact author at cyberpro123@posteo.com
|
|
from collections.abc import Callable
|
|
import curses
|
|
import datetime
|
|
import time
|
|
|
|
import bcrypt
|
|
|
|
import common
|
|
import sql
|
|
|
|
|
|
class MenuItem:
|
|
def __init__(
|
|
self,
|
|
key: str | int,
|
|
prompt: str,
|
|
action: Callable | str,
|
|
):
|
|
self.key = str(key)[:1]
|
|
self.prompt = prompt
|
|
self.action = action
|
|
|
|
|
|
menus = {
|
|
"main": [
|
|
MenuItem(1, "Manage Users", "users"),
|
|
MenuItem(2, "placeholder", "plcohlder"),
|
|
MenuItem(3, "placeholder", "plcohlder"),
|
|
MenuItem(4, "placeholder", "plcohlder"),
|
|
MenuItem(5, "placeholder", "plcohlder"),
|
|
MenuItem(6, "placeholder", "plcohlder"),
|
|
MenuItem(9, "Close Menu", "close"),
|
|
],
|
|
}
|
|
|
|
|
|
def getKeys(menu: list):
|
|
output = []
|
|
for i in menu:
|
|
output.append(i.key)
|
|
return output
|
|
|
|
|
|
def doMenu(screen):
|
|
exitMenu = False
|
|
char = 0
|
|
row = 0
|
|
optionsStart = 0
|
|
menu = menus["main"]
|
|
while not exitMenu:
|
|
screen.clear()
|
|
height, width = screen.getmaxyx()
|
|
|
|
for num, item in enumerate(menu):
|
|
screen.addstr(num + optionsStart, 0, f"[{item.key}]: {item.prompt}")
|
|
if chr(char) in getKeys(menu):
|
|
common.logger.info("Valid Key Defected")
|
|
else:
|
|
match char:
|
|
case curses.KEY_DOWN:
|
|
row += 1
|
|
if row == (optionsStart + len(menu)):
|
|
row = optionsStart
|
|
case curses.KEY_UP:
|
|
row -= 1
|
|
if row == (optionsStart - 1):
|
|
row = optionsStart + len(menu) - 1
|
|
screen.move(row, 1)
|
|
char = screen.getch()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
common.init()
|
|
curses.wrapper(doMenu)
|