From d28fdaf492c2ef618d9c54cf324bfecaad87cd32 Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Mon, 8 Sep 2025 22:33:03 -0700 Subject: [PATCH] feat: export email in export-users --- joint_teapot/app.py | 8 ++++++++ joint_teapot/workers/canvas.py | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/joint_teapot/app.py b/joint_teapot/app.py index cc9f374..e83b014 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -39,6 +39,14 @@ def export_users_to_csv(output_file: Path = Argument("students.csv")) -> None: tea.pot.canvas.export_users_to_csv(output_file) +@app.command( + "export-wrong-email-users", + help="export users with wrong email from canvas in stdout", +) +def export_wrong_email_users() -> None: + tea.pot.canvas.export_wrong_email_users() + + @app.command( "invite-to-teams", help="invite all canvas students to gitea teams by team name" ) diff --git a/joint_teapot/workers/canvas.py b/joint_teapot/workers/canvas.py index 83e6834..c66da16 100644 --- a/joint_teapot/workers/canvas.py +++ b/joint_teapot/workers/canvas.py @@ -61,6 +61,11 @@ class Canvas: self.grade_filename = grade_filename logger.debug("Canvas initialized") + def export_wrong_email_users(self) -> None: + for user in self.users: + if not user.email.endswith("@sjtu.edu.cn"): + print(user.email) + def export_users_to_csv(self, filename: Path) -> None: with open(filename, mode="w", newline="") as file: writer = csv.writer(file)