initial commit
This commit is contained in:
1 parent
af59a90c31
commit
ef498e4a72
114 files changed
+11047
No files matched your search
+36
@@ -0,0 +1,36 @@
|
||||
import argparse
|
||||
import os
|
||||
|
||||
import switch_client
|
||||
import todo
|
||||
from menu import get_menu_items, get_site_links_html, get_treeframe_url
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Log in to the switch and discover its menu tree.")
|
||||
parser.add_argument("--dump-html", metavar="DIR", help="Save fetched HTML pages into this directory for debugging.")
|
||||
args = parser.parse_args()
|
||||
|
||||
session = switch_client.get_session()
|
||||
|
||||
if args.dump_html:
|
||||
os.makedirs(args.dump_html, exist_ok=True)
|
||||
root_html = switch_client.fetch(session, "/")
|
||||
with open(os.path.join(args.dump_html, "root.html"), "w", encoding="utf-8") as f:
|
||||
f.write(root_html)
|
||||
|
||||
treeframe_url = get_treeframe_url(session)
|
||||
site_links_html = get_site_links_html(session, treeframe_url)
|
||||
with open(os.path.join(args.dump_html, "site_links.html"), "w", encoding="utf-8") as f:
|
||||
f.write(site_links_html)
|
||||
|
||||
items = get_menu_items(session)
|
||||
for item in items:
|
||||
print(f"{' ' * item.depth}{item.label} -> {item.href}")
|
||||
|
||||
todo.refresh_todo(items)
|
||||
print(f"\nWrote {todo.TODO_PATH}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user