-
-
Notifications
You must be signed in to change notification settings - Fork 4
Document the process for sending emails #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PeterJCLaw
wants to merge
5
commits into
main
Choose a base branch
from
document-sending
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e233784
Make this script runnable
PeterJCLaw a8768be
Document the send script better
PeterJCLaw 4a17b46
Add the script I use to pre-process the CSVs
PeterJCLaw fe937d6
Document the current processes for sending emails
PeterJCLaw 4059602
Explain what processing is done
PeterJCLaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| """ | ||
| Script for processing an exported CSV from the "Combined" tab of the current | ||
PeterJCLaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| year's "Teams Organisation (internal)" spreadsheet for use in emailing teams. | ||
| Outputs to standard output, typical usage is to redirect that to a file. | ||
| """ | ||
|
|
||
| import argparse | ||
| import csv | ||
| import re | ||
| import sys | ||
| from typing import TextIO | ||
|
|
||
|
|
||
| def pascal_case(text: str) -> str: | ||
| if text.isupper(): | ||
| return text | ||
| return re.sub(r'\W+', '', text.title()) | ||
|
|
||
|
|
||
| def main(input_csv: TextIO, in_place: bool) -> None: | ||
| rows = list(csv.reader(input_csv)) | ||
|
|
||
| super_header_row = rows.pop(0) | ||
| header_row = rows.pop(0) | ||
|
|
||
| try: | ||
| supervisor_offset = super_header_row.index('Supervisor') | ||
| secondary_contact_offset = super_header_row.index('Secondary Contact') | ||
| secondary_contact_end = super_header_row.index('Kit Info') | ||
| except ValueError as e: | ||
| raise ValueError(f"Badly formed input file: {e}") from e | ||
|
|
||
| status_col = header_row.index('Status') | ||
|
|
||
| # Update in place to ensure the new values are written back | ||
| header_row = [pascal_case(x) for x in header_row] | ||
|
|
||
| for idx, value in enumerate(header_row): | ||
| if idx < supervisor_offset or idx > secondary_contact_end: | ||
| continue | ||
| if idx < secondary_contact_offset: | ||
| header_row[idx] = 'Primary' + value | ||
| else: | ||
| header_row[idx] = 'Secondary' + value | ||
|
|
||
| rows = [x for x in rows if x[status_col] not in ('Dropped Out', '')] | ||
|
|
||
| if in_place: | ||
| input_csv.seek(0) | ||
| input_csv.truncate() | ||
| output = input_csv | ||
| else: | ||
| output = sys.stdout | ||
|
|
||
| csv.writer(output).writerow(header_row) | ||
| csv.writer(output).writerows(rows) | ||
|
|
||
|
|
||
| def parse_args() -> argparse.Namespace: | ||
| parser = argparse.ArgumentParser( | ||
| description=__doc__, | ||
| formatter_class=argparse.RawDescriptionHelpFormatter, | ||
| ) | ||
| parser.add_argument( | ||
| 'input_csv', | ||
| help="CSV file to process", | ||
| type=argparse.FileType(mode='r+'), | ||
| ) | ||
| parser.add_argument( | ||
| '--in-place', | ||
| action='store_true', | ||
| default=False, | ||
| help="Update the file in place (discouraged)", | ||
| ) | ||
| return parser.parse_args() | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main(**(parse_args().__dict__)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also do this with an extra spreadsheet that includes all the primary contacts and the secondary contacts. This list should be largely static.
Then we can remain within email clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requiring a script to send emails feels overkill to me, and is definitely a barrier for some people (yes, GitHub may also be a barrier, but a very different kind).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first step being having to set up a Python virtual environment would make it a massive barrier for a lot of people and I don't think is a reasonable expectation for our volunteers to have to know/be able to do this. GitHub can be a barrier too, but much easier to overcome imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for these comments. I appreciate the desire to ensure our processes are accessible and consider various alternatives. However the purpose of this PR is not to propose a new process, but rather to document one which has been in place for the substantial majority of this competition year.
While alternatives may be possible (though the requirements are more complicated than might be expected and the alternatives here aren't easily workable), a number of options were considered and this route chosen as the simplest given the volunteers currently responsible & involved. Documenting the process as it stands does not prevent it being changed in future, though it does immediately make it more accessible than the status quo (namely: no documentation).
Even if the process here isn't optimal, it strikes me as far better that it is documented than that it remain undocumented.