From d9753e01f0e41e5928c768f20eeda6674ee969c9 Mon Sep 17 00:00:00 2001 From: Brent Gawryluik Date: Mon, 9 Jul 2018 21:49:37 -0700 Subject: [PATCH 1/4] Add helper function to print header --- days/01-03-datetimes/my_code/helpers.py | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 days/01-03-datetimes/my_code/helpers.py diff --git a/days/01-03-datetimes/my_code/helpers.py b/days/01-03-datetimes/my_code/helpers.py new file mode 100644 index 00000000..e2f83b72 --- /dev/null +++ b/days/01-03-datetimes/my_code/helpers.py @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------ +# Helper file for 100 Days of Code +# +# My first 'libaray' code +# +# Brent Gawryluik +# 2018-07-09 +# ------------------------------------------------------------------------ + + +def print_header(title): + + border_length = len(title) + 12 + + print() + print_border(border_length) + print_title(title) + print_border(border_length) + print() + +def print_border(length): + for _ in range(length): + print('-', end='', flush=True) + + print() + + +def print_title(title): + print(' ', end='', flush=True) + print(title) From 2bbcea8a8820d35f5ca5f084f2b4901607952ddb Mon Sep 17 00:00:00 2001 From: Brent Gawryluik Date: Mon, 9 Jul 2018 21:50:20 -0700 Subject: [PATCH 2/4] Add main program file to call print header --- days/01-03-datetimes/my_code/program.py | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 days/01-03-datetimes/my_code/program.py diff --git a/days/01-03-datetimes/my_code/program.py b/days/01-03-datetimes/my_code/program.py new file mode 100644 index 00000000..9336b447 --- /dev/null +++ b/days/01-03-datetimes/my_code/program.py @@ -0,0 +1,26 @@ +# ------------------------------------------------------------------------ +# 100 Days of Code +# Day 1-3 +# +# Pomadaro Timer +# - Playing with Datetimes... +# +# Brent Gawryluik +# 2018-07-09 +# ------------------------------------------------------------------------ + +import helpers + + +def main(): + helpers.print_header('Pomadaro Timer') + work_duration = get_duration_input("WORK") + rest_duration = get_duration_input("REST") + + +def get_duration_input(activity): + return input("Please enter for how many minutes you would like to {}: ".format(activity)) + + +if __name__ == '__main__': + main() From f326ae6eb7939dc7fc589765c7234f12df353cb5 Mon Sep 17 00:00:00 2001 From: Brent G Date: Tue, 10 Jul 2018 23:44:08 -0700 Subject: [PATCH 3/4] Add requirements for progressbar2 --- days/01-03-datetimes/my_code/requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 days/01-03-datetimes/my_code/requirements.txt diff --git a/days/01-03-datetimes/my_code/requirements.txt b/days/01-03-datetimes/my_code/requirements.txt new file mode 100644 index 00000000..d8585bae --- /dev/null +++ b/days/01-03-datetimes/my_code/requirements.txt @@ -0,0 +1 @@ +progressbar2 From 7e850d0c0d0feba7a3a6a41ddb15265321c2cbe0 Mon Sep 17 00:00:00 2001 From: Brent G Date: Tue, 10 Jul 2018 23:44:58 -0700 Subject: [PATCH 4/4] Add functions for timing and displaying tasks --- days/01-03-datetimes/my_code/program.py | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/days/01-03-datetimes/my_code/program.py b/days/01-03-datetimes/my_code/program.py index 9336b447..0a8ef72d 100644 --- a/days/01-03-datetimes/my_code/program.py +++ b/days/01-03-datetimes/my_code/program.py @@ -4,23 +4,52 @@ # # Pomadaro Timer # - Playing with Datetimes... +# - or time, anyway... # # Brent Gawryluik # 2018-07-09 # ------------------------------------------------------------------------ import helpers +import progressbar +import time def main(): helpers.print_header('Pomadaro Timer') work_duration = get_duration_input("WORK") rest_duration = get_duration_input("REST") + display_timer(work_duration, 'WORK') + display_timer(rest_duration, 'REST') + print() + print('Exiting the Pomadaro timer process.') def get_duration_input(activity): - return input("Please enter for how many minutes you would like to {}: ".format(activity)) + return int(input("Please enter a number for how many minutes you would like to {}: ".format(activity))) +def display_timer(duration, activity): + + print() + print("Starting new {} task".format(activity)) + + if duration == 1: + print("Now displaying {} timer for {} minute...".format(activity, duration)) + elif duration > 1: + print("Now displaying {} timer for {} minutes...".format(activity, duration)) + + print () + + bar = progressbar.ProgressBar(widgets=[ + progressbar.Bar(), + ]) + + for i in bar(range(duration *60)): + time.sleep(1) + + print() + print("{} task is done".format(activity)) + if __name__ == '__main__': main()