(20260309) Added new 'mode' for formatting the muster roll'.

This commit is contained in:
2026-03-09 17:25:35 +05:30
parent c3ab2e4d9a
commit 4350435a01
8 changed files with 94 additions and 16 deletions
@@ -0,0 +1,54 @@
from utils_v2.string import json
from scripts import common
from tcaoff.async_tcaoff import AsyncTheCAOffice
import asyncio
import datetime
# Explicitly mention the expected file paths for other devs to maintain:
print("PROJ. DIR. :", common.PROJ_DIR)
print("COSEC CREDS :", common.COSEC_CREDS_FILE)
print("TCAOFF CREDS:", common.TCAOFF_CREDS_FILE)
# Read required credentials:
cosec_creds = json.from_file(common.COSEC_CREDS_FILE)
tcaoff_creds = json.from_file(common.TCAOFF_CREDS_FILE)
# Create the clients:
tcaoff_client = AsyncTheCAOffice(
username = tcaoff_creds["creds"]["username"],
password = tcaoff_creds["creds"]["password"],
debug = True,
debug_only_errors = False,
)
async def main():
# Ensure login:
if not await tcaoff_client.login():
return
# Get the data:
raw_records = await tcaoff_client.attendance_register(
target_month = datetime.datetime.now(),
raise_exception = True
)
# Format the data for preview:
formatted_records = []
for r in raw_records:
cosec_data = json.from_string(r.get("json_notes", "{}")).get("cosec", {})
if cosec_data:
cosec_data.update({
"cosecId": r["pseudonym"],
"tcaoffId": r["user_id"],
})
formatted_records.append(cosec_data)
# Show the formatted data for debugging:
print(f"RECORDS ({len(formatted_records)}):", json.to_string(formatted_records))
print(f"Found {len(formatted_records)} record(s).")
# Log out:
await tcaoff_client.logout()
asyncio.run(main())