This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch display
in repository https://gitbox.apache.org/repos/asf/steve.git
The following commit(s) were added to refs/heads/display by this push:
new c663c32 uv run ruff format
c663c32 is described below
commit c663c32c21d6feb5a751560eb32c40480d6c8467
Author: tison <[email protected]>
AuthorDate: Sat Feb 28 11:34:16 2026 +0800
uv run ruff format
Signed-off-by: tison <[email protected]>
---
v3/server/bin/mail-voters.py | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/v3/server/bin/mail-voters.py b/v3/server/bin/mail-voters.py
index b1a2ed2..1fca181 100755
--- a/v3/server/bin/mail-voters.py
+++ b/v3/server/bin/mail-voters.py
@@ -43,20 +43,20 @@ def main(eid, template_file):
"""
# Load the election
election = steve.election.Election(DB_FNAME, eid)
-
+
# Get metadata for context
metadata = election.get_metadata()
-
+
# Get list of eligible voters
voters = election.get_voters_for_email()
-
+
if not voters:
- _LOGGER.info(f"No eligible voters found for election {eid}")
+ _LOGGER.info(f'No eligible voters found for election {eid}')
return
-
+
# Load the EZT template
template = ezt.Template(template_file)
-
+
# Send email to each voter
for voter in voters:
# Prepare data dictionary for template rendering
@@ -64,22 +64,22 @@ def main(eid, template_file):
'voter': voter, # edict with pid, name, email
'election': metadata, # edict with eid, title, owner_pid, etc.
}
-
+
# Render the template to a StringIO stream
output = io.StringIO()
template.generate(output, data)
rendered_body = output.getvalue()
-
+
# Send the email
asfpy.messaging.mail(
- sender="Apache Election Platform <[email protected]>",
+ sender='Apache Election Platform <[email protected]>',
recipient=voter.email,
- subject=f"Vote in Election: {metadata.title}",
+ subject=f'Vote in Election: {metadata.title}',
message=rendered_body,
# Add other parameters as needed (e.g., auth, headers)
)
-
- _LOGGER.info(f"Sent email to {voter.email} for election {eid}")
+
+ _LOGGER.info(f'Sent email to {voter.email} for election {eid}')
if __name__ == '__main__':
@@ -87,18 +87,14 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
- description="Send emails to eligible voters for a given election."
- )
- parser.add_argument(
- '--eid',
- required=True,
- help='Election ID to send emails for.'
+ description='Send emails to eligible voters for a given election.',
)
+ parser.add_argument('--eid', required=True, help='Election ID to send
emails for.')
parser.add_argument(
'--template',
required=True,
- help='Path to the .ezt template file for email body.'
+ help='Path to the .ezt template file for email body.',
)
args = parser.parse_args()
-
+
main(args.eid, args.template)