From 5fd5fb6058460d70503da88f86a75687cf540123 Mon Sep 17 00:00:00 2001 From: deoren Date: Sun, 3 Jun 2018 16:19:10 -0500 Subject: [PATCH 1/2] Add new frequencies: weekly saturday, sunday refs WhyAskWhy/automated-tickets#18 --- automated_tickets.py | 2 ++ automated_tickets_lib.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/automated_tickets.py b/automated_tickets.py index 6eab7db..5cc71a2 100644 --- a/automated_tickets.py +++ b/automated_tickets.py @@ -77,6 +77,8 @@ 'weekly_wednesday', 'weekly_thursday', 'weekly_friday', + 'weekly_saturday', + 'weekly_sunday', 'weekly', 'twice_month', 'monthly', diff --git a/automated_tickets_lib.py b/automated_tickets_lib.py index 55b78d5..bf5e0a5 100644 --- a/automated_tickets_lib.py +++ b/automated_tickets_lib.py @@ -91,6 +91,8 @@ 'weekly_wednesday':TODAY, 'weekly_thursday':TODAY, 'weekly_friday':TODAY, + 'weekly_saturday':TODAY, + 'weekly_sunday':TODAY, 'twice_month':TODAY, 'monthly':MONTH_YEAR, 'twice_year':MONTH_YEAR, From 93beab481f4a08a05126d2d8d8642f88b5e5fc1f Mon Sep 17 00:00:00 2001 From: deoren Date: Sun, 3 Jun 2018 16:23:09 -0500 Subject: [PATCH 2/2] Dedupe frequency list: use DATE_LABEL keys refs WhyAskWhy/automated-tickets#18 --- automated_tickets.py | 22 +++------------------- automated_tickets_lib.py | 8 ++++---- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/automated_tickets.py b/automated_tickets.py index 5cc71a2..3620d9f 100644 --- a/automated_tickets.py +++ b/automated_tickets.py @@ -63,29 +63,13 @@ ) # This will need to be broken up later by the script -# WARNING: This needs to be kept in sync with DATE_LABEL within -# the library file. parser.add_argument( '--event_schedule', action='store', required=True, - choices=[ - 'daily', - 'twice_week', - 'weekly_monday', - 'weekly_tuesday', - 'weekly_wednesday', - 'weekly_thursday', - 'weekly_friday', - 'weekly_saturday', - 'weekly_sunday', - 'weekly', - 'twice_month', - 'monthly', - 'twice_year', - 'quarterly', - 'yearly' - ] + + # Reuse keys from DATE_LABEL dict in library file instead of repeating here + choices=list(DATE_LABEL.keys()) ) # NOTE: Probably want to leave this as not required and fall back to checking diff --git a/automated_tickets_lib.py b/automated_tickets_lib.py index bf5e0a5..f35ab60 100644 --- a/automated_tickets_lib.py +++ b/automated_tickets_lib.py @@ -78,10 +78,10 @@ # we will get the same result as what we're doing here TODAY = date.strftime('%Y-%m-%d') -# These entries match up with the event schedule "keywords". For example, -# when daily events are requested, active daily events will result in -# notifications generated which have subject lines that include the value -# that is paired with the keyword below. +# These entries serve both as a mapping of display formats and also as +# valid parameter values. For example, when daily events are requested, +# active daily events will result in notifications generated which have +# subject lines that include the value that is paired with the keyword below. DATE_LABEL = { 'daily':TODAY, 'twice_week':TODAY,