Files

26 lines
841 B
Python

import json
import switch_client
import todo
from extractors.xe_page import fetch_all_tables
PATH = "/FDBSearch.html"
def get_mac_table(session) -> dict:
"""Returns {"summary": {...}, "entries": [...]}.
The per-entry table on this page has no <CAPTION> (just an empty one),
so it can't be looked up by caption like other pages -- fetch_all_tables()
+ table id "1_1" is used instead."""
tables = fetch_all_tables(session, PATH)
summary = next(t["record"] for t in tables if t.get("caption") == "MAC Table")
entries = next(t["rows"] for t in tables if t.get("id") == "1_1")
return {"summary": summary, "entries": entries}
if __name__ == "__main__":
session = switch_client.get_session()
print(json.dumps(get_mac_table(session), indent=2))
todo.mark_implemented(switch_client.BASE_URL + PATH)