taskcheck 0.1.3__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,145 @@
1
+ Metadata-Version: 2.1
2
+ Name: taskcheck
3
+ Version: 0.2.1
4
+ Summary: Automatic scheduler for taskwarrior
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: appdirs>=1.4.4
9
+ Requires-Dist: icalendar>=6.0.1
10
+ Requires-Dist: requests>=2.32.3
11
+
12
+
13
+ > _A non-AI automatic scheduler for taskwarrior (i.e. alternative to skedpal/timehero/flowsavvy/reclaim/trevor/motion)_
14
+
15
+ This is a taskwarrior extension checks if tasks can be completed on time, considering estimated time and working hours.
16
+
17
+ ## Features
18
+
19
+ - [x] Use arbitrarily complex time maps
20
+ - [x] Use ical to block time from scheduling (e.g. for meetings, vacations, etc.)
21
+ - [x] Implement scheduling algorithm for parallely working on multiple tasks
22
+ - [ ] Use Google API to access calendars
23
+ - [ ] Export tasks to iCal calendar and API calendars
24
+
25
+ ## Install
26
+
27
+ 1. `pipx install taskcheck`
28
+ 2. `taskcheck --install`
29
+
30
+ ## How does it work
31
+
32
+ This extension parses your pending and waiting tasks sorted decreasingly by urgency and tries to schedule them in the future.
33
+ It considers their estimated time to schedule all tasks starting from the most urgent one.
34
+
35
+ Taskcheck leverages to UDAs, `estimated` and `time_map`. The `estimated` attribute is
36
+ the expected time to complete the task in hours. The `time_map` is a comma-separated list of strings
37
+ that indicates the hours per day in which you will work on a task (e.g. `work`, `weekend`, etc.).
38
+ The exact correspondence between the `time_map` and the hours of the day is defined in the configuration
39
+ file of taskcheck. For instance:
40
+
41
+ ```toml
42
+ ```toml
43
+ [time_maps]
44
+ # get an error)
45
+ [time_maps.work]
46
+ monday = [[9, 12.30], [14, 17]]
47
+ tuesday = [[9, 12.30], [14, 17]]
48
+ # ...
49
+ ```
50
+
51
+ Taskcheck will also parse online iCal calendars (Google, Apple, etc.) and will match them with your time maps.
52
+ It will then modify the Taskwarrior tasks by adding the `completion_date` attribute with the expected
53
+ date of completion and the `scheduled` attribute with the date in which the task is expected to
54
+ start.
55
+
56
+ It will also print a red line for every task whose `completion_date` is after its `due_date`.
57
+
58
+ In general, it is recommended to run taskcheck rather frequently and at least once at the beginning
59
+ of your working day.
60
+
61
+ ## Algorithms
62
+
63
+ Taskcheck provides two scheduling algorithms: `parallel` and `sequential`.
64
+
65
+ #### Sequential
66
+
67
+ The `sequential` algorithm schedules tasks one after the other. It is the simplest algorithm.
68
+ It looks at your tasks one by one, computes the time slots available for that task, and fills them
69
+ as soon as possible.
70
+
71
+ While it sounds logical, it has a problem.
72
+ While you're working on a task, its remaining estimated time is decreasing, and if your urgency
73
+ depends on the estimated time left, the urgency of the task will decrease as well.
74
+ This is especially problematic for long tasks: imagine if you block your whole week for a single
75
+ task and all the other small tasks, even if urgent, don't get scheduled. After a few days, the
76
+ urgency of the first long task should have decreased.
77
+
78
+ #### Parallel
79
+
80
+ The `parallel` algorithm tries to solve the problem of the `sequential` algorithm.
81
+
82
+ Instead of allocating all the available time for a task until the task is finished, the `parallel`
83
+ algorithm allocates a fixed amount of time for each task (e.g. 1 hour) and then recomputes the
84
+ urgency and restart the allocation procedure.
85
+
86
+ If after 1 hour the long task has decreased urgency, that will be noticed and the newer most urgent
87
+ task will get scheduled in its place.
88
+
89
+ The minimum time for a task is by default 2 hours, but you can change it by tuning the `min_block`
90
+ taskwarrior UDA.
91
+
92
+ The `parallel` algorithm is the default algorithm.
93
+
94
+ ## Configuration
95
+
96
+ `taskcheck --install` allows you to create required and recommended configurations for
97
+ taskwarrior. It will also generate a default configuration file for taskcheck.
98
+
99
+ Below is an example of taskcheck configuration file:
100
+
101
+ ```toml
102
+ [time_maps]
103
+ # in which hours you will work in each day (in 24h format, if you use e.g. 25.67 you will likely
104
+ # get an error)
105
+ [time_maps.work]
106
+ monday = [[9, 12.30], [14, 17]]
107
+ tuesday = [[9, 12.30], [14, 17]]
108
+ wednesday = [[9, 12.30], [14, 17]]
109
+ thursday = [[9, 12.30], [14, 17]]
110
+ friday = [[9, 12.30], [14, 17]]
111
+
112
+ [time_maps.weekend]
113
+ saturday = [[9, 12.30], ]
114
+ sunday = [[9, 12.30], ]
115
+
116
+ [scheduler]
117
+ algorithm = "parallel" # or "sequential", see above
118
+ days_ahead = 1000 # how far go with the schedule (lower values make the computation faster)
119
+
120
+ [calendars]
121
+ # ical calendars can be used to block your time and make the scheduling more precise
122
+ [calendars.1]
123
+ url = "https://your/url/to/calendar.ics"
124
+ expiration = 0.08 # in hours (0.08 hours =~ 5 minutes)
125
+ timezone = "Europe/Rome" # if set, force timezone for this calendar; timezone values are TZ identifiers (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
126
+
127
+ [calendars.holidays]
128
+ url = "https://www.officeholidays.com/ics-clean/italy/milan"
129
+ event_all_day_is_blocking = true
130
+ expiration = 720 # in hours (720 hours = 30 days)
131
+ ```
132
+
133
+ ## Tips and Tricks
134
+
135
+ - You can exclude a task from being scheduled by removing the `time_map` or `estimated` attributes.
136
+ - You can see tasks that you can execute now with the `task ready` report.
137
+ - You can see the schedule for a task in the `scheduling` UDA, e.g. `task scheduling:$(task calc
138
+ tomorrow)` will show you the tasks that include a scheduling for tomorrow.
139
+
140
+ ## CLI Options
141
+
142
+ ```
143
+ -v, --verbose: increase output verbosity
144
+ -i, --install: install taskcheck configuration
145
+ ```
@@ -0,0 +1,134 @@
1
+
2
+ > _A non-AI automatic scheduler for taskwarrior (i.e. alternative to skedpal/timehero/flowsavvy/reclaim/trevor/motion)_
3
+
4
+ This is a taskwarrior extension checks if tasks can be completed on time, considering estimated time and working hours.
5
+
6
+ ## Features
7
+
8
+ - [x] Use arbitrarily complex time maps
9
+ - [x] Use ical to block time from scheduling (e.g. for meetings, vacations, etc.)
10
+ - [x] Implement scheduling algorithm for parallely working on multiple tasks
11
+ - [ ] Use Google API to access calendars
12
+ - [ ] Export tasks to iCal calendar and API calendars
13
+
14
+ ## Install
15
+
16
+ 1. `pipx install taskcheck`
17
+ 2. `taskcheck --install`
18
+
19
+ ## How does it work
20
+
21
+ This extension parses your pending and waiting tasks sorted decreasingly by urgency and tries to schedule them in the future.
22
+ It considers their estimated time to schedule all tasks starting from the most urgent one.
23
+
24
+ Taskcheck leverages to UDAs, `estimated` and `time_map`. The `estimated` attribute is
25
+ the expected time to complete the task in hours. The `time_map` is a comma-separated list of strings
26
+ that indicates the hours per day in which you will work on a task (e.g. `work`, `weekend`, etc.).
27
+ The exact correspondence between the `time_map` and the hours of the day is defined in the configuration
28
+ file of taskcheck. For instance:
29
+
30
+ ```toml
31
+ ```toml
32
+ [time_maps]
33
+ # get an error)
34
+ [time_maps.work]
35
+ monday = [[9, 12.30], [14, 17]]
36
+ tuesday = [[9, 12.30], [14, 17]]
37
+ # ...
38
+ ```
39
+
40
+ Taskcheck will also parse online iCal calendars (Google, Apple, etc.) and will match them with your time maps.
41
+ It will then modify the Taskwarrior tasks by adding the `completion_date` attribute with the expected
42
+ date of completion and the `scheduled` attribute with the date in which the task is expected to
43
+ start.
44
+
45
+ It will also print a red line for every task whose `completion_date` is after its `due_date`.
46
+
47
+ In general, it is recommended to run taskcheck rather frequently and at least once at the beginning
48
+ of your working day.
49
+
50
+ ## Algorithms
51
+
52
+ Taskcheck provides two scheduling algorithms: `parallel` and `sequential`.
53
+
54
+ #### Sequential
55
+
56
+ The `sequential` algorithm schedules tasks one after the other. It is the simplest algorithm.
57
+ It looks at your tasks one by one, computes the time slots available for that task, and fills them
58
+ as soon as possible.
59
+
60
+ While it sounds logical, it has a problem.
61
+ While you're working on a task, its remaining estimated time is decreasing, and if your urgency
62
+ depends on the estimated time left, the urgency of the task will decrease as well.
63
+ This is especially problematic for long tasks: imagine if you block your whole week for a single
64
+ task and all the other small tasks, even if urgent, don't get scheduled. After a few days, the
65
+ urgency of the first long task should have decreased.
66
+
67
+ #### Parallel
68
+
69
+ The `parallel` algorithm tries to solve the problem of the `sequential` algorithm.
70
+
71
+ Instead of allocating all the available time for a task until the task is finished, the `parallel`
72
+ algorithm allocates a fixed amount of time for each task (e.g. 1 hour) and then recomputes the
73
+ urgency and restart the allocation procedure.
74
+
75
+ If after 1 hour the long task has decreased urgency, that will be noticed and the newer most urgent
76
+ task will get scheduled in its place.
77
+
78
+ The minimum time for a task is by default 2 hours, but you can change it by tuning the `min_block`
79
+ taskwarrior UDA.
80
+
81
+ The `parallel` algorithm is the default algorithm.
82
+
83
+ ## Configuration
84
+
85
+ `taskcheck --install` allows you to create required and recommended configurations for
86
+ taskwarrior. It will also generate a default configuration file for taskcheck.
87
+
88
+ Below is an example of taskcheck configuration file:
89
+
90
+ ```toml
91
+ [time_maps]
92
+ # in which hours you will work in each day (in 24h format, if you use e.g. 25.67 you will likely
93
+ # get an error)
94
+ [time_maps.work]
95
+ monday = [[9, 12.30], [14, 17]]
96
+ tuesday = [[9, 12.30], [14, 17]]
97
+ wednesday = [[9, 12.30], [14, 17]]
98
+ thursday = [[9, 12.30], [14, 17]]
99
+ friday = [[9, 12.30], [14, 17]]
100
+
101
+ [time_maps.weekend]
102
+ saturday = [[9, 12.30], ]
103
+ sunday = [[9, 12.30], ]
104
+
105
+ [scheduler]
106
+ algorithm = "parallel" # or "sequential", see above
107
+ days_ahead = 1000 # how far go with the schedule (lower values make the computation faster)
108
+
109
+ [calendars]
110
+ # ical calendars can be used to block your time and make the scheduling more precise
111
+ [calendars.1]
112
+ url = "https://your/url/to/calendar.ics"
113
+ expiration = 0.08 # in hours (0.08 hours =~ 5 minutes)
114
+ timezone = "Europe/Rome" # if set, force timezone for this calendar; timezone values are TZ identifiers (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
115
+
116
+ [calendars.holidays]
117
+ url = "https://www.officeholidays.com/ics-clean/italy/milan"
118
+ event_all_day_is_blocking = true
119
+ expiration = 720 # in hours (720 hours = 30 days)
120
+ ```
121
+
122
+ ## Tips and Tricks
123
+
124
+ - You can exclude a task from being scheduled by removing the `time_map` or `estimated` attributes.
125
+ - You can see tasks that you can execute now with the `task ready` report.
126
+ - You can see the schedule for a task in the `scheduling` UDA, e.g. `task scheduling:$(task calc
127
+ tomorrow)` will show you the tasks that include a scheduling for tomorrow.
128
+
129
+ ## CLI Options
130
+
131
+ ```
132
+ -v, --verbose: increase output verbosity
133
+ -i, --install: install taskcheck configuration
134
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "taskcheck"
3
- version = "0.1.3"
3
+ version = "0.2.1"
4
4
  description = "Automatic scheduler for taskwarrior"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -0,0 +1,48 @@
1
+ import tomllib
2
+ import argparse
3
+
4
+ from taskcheck.parallel import check_tasks_parallel
5
+ from taskcheck.sequential import check_tasks_sequentially
6
+ from taskcheck.common import config_dir
7
+
8
+ arg_parser = argparse.ArgumentParser()
9
+ arg_parser.add_argument(
10
+ "-v", "--verbose", action="store_true", help="increase output verbosity"
11
+ )
12
+ arg_parser.add_argument(
13
+ "-i",
14
+ "--install",
15
+ action="store_true",
16
+ help="install the UDAs, required settings, and default config file",
17
+ )
18
+
19
+ args = arg_parser.parse_args()
20
+
21
+
22
+ # Load working hours and exceptions from TOML file
23
+ def load_config():
24
+ with open(config_dir / "taskcheck.toml", "rb") as f:
25
+ config = tomllib.load(f)
26
+ return config
27
+
28
+
29
+ def main():
30
+ # Load data and check tasks
31
+ if args.install:
32
+ from taskcheck.install import install
33
+
34
+ install()
35
+ return
36
+
37
+ config = load_config()
38
+ algo = config["scheduler"].get("algorithm", "parallel")
39
+ if algo == "parallel":
40
+ check_tasks_parallel(config, verbose=args.verbose)
41
+ elif algo == "sequential":
42
+ check_tasks_sequentially(config, verbose=args.verbose)
43
+ else:
44
+ raise ValueError(f"Unknown algorithm: {algo}")
45
+
46
+
47
+ if __name__ == "__main__":
48
+ main()
@@ -0,0 +1,184 @@
1
+ import subprocess
2
+ import json
3
+ from datetime import datetime, timedelta
4
+ from pathlib import Path
5
+ import appdirs
6
+
7
+ from taskcheck.ical import ical_to_dict
8
+
9
+ config_dir = Path(appdirs.user_config_dir("task"))
10
+
11
+ # Taskwarrior status to avoid
12
+ AVOID_STATUS = ["completed", "deleted", "recurring"]
13
+
14
+ long_range_time_map = {}
15
+
16
+
17
+ # Get tasks from Taskwarrior and sort by urgency
18
+ def get_tasks():
19
+ result = subprocess.run(["task", "export"], capture_output=True, text=True)
20
+ tasks = json.loads(result.stdout)
21
+ return sorted(
22
+ (task for task in tasks if "estimated" in task),
23
+ key=lambda t: -t.get("urgency", 0),
24
+ )
25
+
26
+
27
+ def hours_to_decimal(hour):
28
+ return int(hour) + (hour - int(hour)) * 100 / 60
29
+
30
+
31
+ def hours_to_time(hour):
32
+ hours = int(hour)
33
+ minutes = int((hour - hours) * 100)
34
+ return datetime.strptime(f"{hours}:{minutes}", "%H:%M").time()
35
+
36
+
37
+ def time_to_decimal(time):
38
+ # round to 2 digits after the point
39
+ return time.hour + time.minute / 60
40
+
41
+
42
+ def get_available_hours(time_map, date, calendars, verbose=False):
43
+ day_of_week = date.strftime("%A").lower()
44
+ schedule = time_map.get(day_of_week, [])
45
+ available_hours = sum(
46
+ hours_to_decimal(end) - hours_to_decimal(start) for start, end in schedule
47
+ )
48
+
49
+ blocked_hours = 0
50
+ for schedule_start, schedule_end in schedule:
51
+ # schedule_start and schedule_end are numbers, actually
52
+ # so let's convert them to datetime.time objects
53
+ schedule_start = hours_to_time(schedule_start)
54
+ schedule_end = hours_to_time(schedule_end)
55
+ schedule_blocked_hours = 0
56
+ for calendar in calendars:
57
+ for event in calendar:
58
+ # we use str to make object serializable as jsons
59
+ if isinstance(event["start"], str):
60
+ event["start"] = datetime.fromisoformat(event["start"])
61
+ if isinstance(event["end"], str):
62
+ event["end"] = datetime.fromisoformat(event["end"])
63
+
64
+ if event["start"].date() > date:
65
+ break
66
+ elif event["end"].date() < date:
67
+ continue
68
+
69
+ # check if the event overlaps with one of the working hours
70
+ event_start = event["start"].time()
71
+ event_end = event["end"].time()
72
+ if event["start"].date() < date:
73
+ event_start = datetime(date.year, date.month, date.day, 0, 0).time()
74
+ if event["end"].date() > date:
75
+ event_end = datetime(date.year, date.month, date.day, 23, 59).time()
76
+
77
+ if event_start < schedule_end and event_end > schedule_start:
78
+ schedule_blocked_hours += time_to_decimal(
79
+ min(schedule_end, event_end)
80
+ ) - time_to_decimal(max(schedule_start, event_start))
81
+ if verbose and schedule_blocked_hours > 0:
82
+ print(
83
+ f"Blocked hours on {date} between {schedule_start} and {schedule_end}: {schedule_blocked_hours}"
84
+ )
85
+ blocked_hours += schedule_blocked_hours
86
+ available_hours -= blocked_hours
87
+ return available_hours
88
+
89
+
90
+ def pdth_to_hours(duration_str):
91
+ # string format is P#DT#H
92
+ # with D and H optional
93
+ duration_str = duration_str[1:] # Remove leading "P"
94
+ days, hours = 0, 0
95
+ if "D" in duration_str:
96
+ days, duration_str = duration_str.split("D")
97
+ days = int(days)
98
+ if "H" in duration_str:
99
+ hours = int(duration_str.split("T")[1].split("H")[0])
100
+ return days * 24 + hours
101
+
102
+
103
+ def hours_to_pdth(hours):
104
+ days = hours // 24
105
+ hours = hours % 24
106
+ return f"P{days}DT{hours}H"
107
+
108
+
109
+ def get_long_range_time_map(
110
+ time_maps, time_map_names, days_ahead, calendars, verbose=False
111
+ ):
112
+ key = ",".join(time_map_names)
113
+ if key in long_range_time_map:
114
+ task_time_map = long_range_time_map[key]
115
+ else:
116
+ if verbose:
117
+ print(f"Calculating long range time map for {key}")
118
+ task_time_map = []
119
+ for d in range(days_ahead):
120
+ date = datetime.today().date() + timedelta(days=d)
121
+ daily_hours = 0
122
+ for time_map_name in time_map_names:
123
+ if time_map_name not in time_maps:
124
+ raise ValueError(f"Time map '{time_map_name}' does not exist.")
125
+ time_map = time_maps[time_map_name]
126
+ daily_hours += get_available_hours(time_map, date, calendars)
127
+ task_time_map.append(daily_hours)
128
+ long_range_time_map[key] = task_time_map
129
+
130
+ today_time = time_to_decimal(datetime.now().time())
131
+ today_weekday = datetime.today().strftime("%A").lower()
132
+ today_used_hours = 0
133
+ # compare with the time_maps of today
134
+ for time_map_name in time_map_names:
135
+ time_map = time_maps[time_map_name].get(today_weekday)
136
+ if time_map:
137
+ for schedule_start, schedule_end in time_map:
138
+ if schedule_start <= today_time <= schedule_end:
139
+ today_used_hours += today_time - schedule_start
140
+ break
141
+ elif today_time > schedule_end:
142
+ today_used_hours += schedule_end - schedule_start
143
+ return task_time_map, today_used_hours
144
+
145
+
146
+ def mark_end_date(
147
+ due_date, end_date, start_date, scheduling_note, id, description=None
148
+ ):
149
+ start_end_fields = [f"scheduled:{start_date}", f"completion_date:{end_date}"]
150
+
151
+ subprocess.run(
152
+ [
153
+ "task",
154
+ str(id),
155
+ "modify",
156
+ *start_end_fields,
157
+ f'scheduling:"{scheduling_note}"',
158
+ ],
159
+ stdout=subprocess.DEVNULL,
160
+ stderr=subprocess.DEVNULL,
161
+ )
162
+ if due_date is not None and end_date > due_date:
163
+ # print in bold red using ANSI escape codes
164
+ description = "('" + description + "')" if description is not None else ""
165
+ print(f"\033[1;31mTask {id} {description} may not be completed on time\033[0m")
166
+
167
+
168
+ def get_calendars(config, verbose=False):
169
+ calendars = []
170
+ for calname in config["calendars"]:
171
+ calendar = config["calendars"][calname]
172
+ calendar = ical_to_dict(
173
+ calendar["url"],
174
+ config["scheduler"]["days_ahead"],
175
+ all_day=calendar["event_all_day_is_blocking"],
176
+ expiration=calendar["expiration"],
177
+ verbose=verbose,
178
+ tz_name=calendar.get("timezone"),
179
+ )
180
+ calendar.sort(key=lambda e: e["start"])
181
+ calendars.append(calendar)
182
+ if verbose:
183
+ print(f"Loaded {len(calendars)} calendars")
184
+ return calendars
@@ -0,0 +1,154 @@
1
+ import subprocess
2
+ from taskcheck.common import config_dir
3
+
4
+
5
+ default_config = """
6
+ [time_maps]
7
+ [time_maps.work]
8
+ monday = [[9, 12.30], [14, 17]]
9
+ tuesday = [[9, 12.30], [14, 17]]
10
+ wednesday = [[9, 12.30], [14, 17]]
11
+ thursday = [[9, 12.30], [14, 17]]
12
+ friday = [[9, 12.30], [14, 17]]
13
+
14
+ [scheduler]
15
+ algorithm = "parallel"
16
+ days_ahead = 365
17
+ """
18
+
19
+
20
+ def apply_config(key, value):
21
+ subprocess.run(["task", "config", key, value], stdout=subprocess.DEVNULL)
22
+
23
+
24
+ def install():
25
+ """
26
+ Adds the required and optional settings explaining them to the user.
27
+ Also initialize the config file with some sane default.
28
+ """
29
+
30
+ # Define the required configurations
31
+ required_configs = [
32
+ ("uda.time_map.type", "string"),
33
+ ("uda.time_map.label", "Time Map"),
34
+ ("uda.time_map.default", "work"),
35
+ ("uda.estimated.type", "duration"),
36
+ ("uda.estimated.label", "Estimated Time"),
37
+ ("uda.completion_date.type", "date"),
38
+ ("uda.completion_date.label", "Expected Completion Date"),
39
+ ("uda.scheduling.type", "string"),
40
+ ("uda.scheduling.label", "Scheduling"),
41
+ ("uda.min_block.type", "numeric"),
42
+ ("uda.min_block.label", "Minimum Time Block"),
43
+ ("uda.min_block.default", "2"),
44
+ ("recurrence.confirmation", "no"),
45
+ ]
46
+
47
+ # Optional configurations
48
+ optional_configs = [
49
+ ("urgency.uda.estimated.PT1H.coefficient", "1"),
50
+ ("urgency.uda.estimated.PT2H.coefficient", "2.32"),
51
+ ("urgency.uda.estimated.PT3H.coefficient", "3.67"),
52
+ ("urgency.uda.estimated.PT4H.coefficient", "4.64"),
53
+ ("urgency.uda.estimated.PT5H.coefficient", "5.39"),
54
+ ("urgency.uda.estimated.PT6H.coefficient", "6.02"),
55
+ ("urgency.uda.estimated.PT7H.coefficient", "6.56"),
56
+ ("urgency.uda.estimated.PT8H.coefficient", "7.03"),
57
+ ("urgency.uda.estimated.PT9H.coefficient", "7.45"),
58
+ ("urgency.uda.estimated.PT10H.coefficient", "7.82"),
59
+ ("urgency.uda.estimated.PT11H.coefficient", "8.16"),
60
+ ("urgency.uda.estimated.PT12H.coefficient", "8.47"),
61
+ ("urgency.uda.estimated.PT13H.coefficient", "8.75"),
62
+ ("urgency.uda.estimated.PT14H.coefficient", "9.01"),
63
+ ("urgency.uda.estimated.PT15H.coefficient", "9.25"),
64
+ ("urgency.uda.estimated.PT16H.coefficient", "9.47"),
65
+ ("urgency.uda.estimated.PT17H.coefficient", "9.68"),
66
+ ("urgency.uda.estimated.PT18H.coefficient", "9.87"),
67
+ ("urgency.uda.estimated.PT19H.coefficient", "10.05"),
68
+ ("urgency.uda.estimated.PT20H.coefficient", "10.22"),
69
+ ("urgency.uda.estimated.PT21H.coefficient", "10.38"),
70
+ ("urgency.uda.estimated.PT22H.coefficient", "10.53"),
71
+ ("urgency.uda.estimated.PT23H.coefficient", "10.67"),
72
+ ("urgency.uda.estimated.PT24H.coefficient", "10.80"),
73
+ ("urgency.uda.estimated.PT25H.coefficient", "10.93"),
74
+ ("urgency.uda.estimated.PT26H.coefficient", "11.05"),
75
+ ("urgency.uda.estimated.PT27H.coefficient", "11.16"),
76
+ ("urgency.uda.estimated.PT28H.coefficient", "11.27"),
77
+ ("urgency.uda.estimated.PT29H.coefficient", "11.37"),
78
+ ("urgency.uda.estimated.PT30H.coefficient", "11.47"),
79
+ ("urgency.uda.estimated.PT31H.coefficient", "11.56"),
80
+ ("urgency.uda.estimated.PT32H.coefficient", "11.65"),
81
+ ("urgency.uda.estimated.PT33H.coefficient", "11.73"),
82
+ ("urgency.uda.estimated.PT34H.coefficient", "11.81"),
83
+ ("urgency.uda.estimated.PT35H.coefficient", "11.89"),
84
+ ("urgency.uda.estimated.PT36H.coefficient", "11.96"),
85
+ (
86
+ "report.ready.columns",
87
+ "id,start.age,entry.age,depends.indicator,priority,project,tags,recur.indicator,scheduled.relative,due.relative,until.remaining,description,urgency",
88
+ ),
89
+ ("journal.info", "0"),
90
+ ("urgency.inherit", "1"),
91
+ ("urgency.blocked.coefficient", "0"),
92
+ ("urgency.blocking.coefficient", "0"),
93
+ ("urgency.waiting.coefficient", "0"),
94
+ ("urgency.scheduled.coefficient", "0"),
95
+ ]
96
+
97
+ answer = input(
98
+ """
99
+ _________________________________________________________________________________________
100
+ Required configuration for taskcheck includes:
101
+ - 3 UDA fields
102
+ - turning off confirmation for recurring tasks
103
+
104
+ Do you want to continue? [y/N] """
105
+ )
106
+ if answer.lower() not in ["y", "yes"]:
107
+ return
108
+
109
+ answer = input(
110
+ """
111
+ _________________________________________________________________________________________
112
+ Optional configuration for taskcheck includes:
113
+ - urgency coefficients for estimated time (up to 36 hour duration)
114
+ - better `ready` report columns
115
+ - turning off printing journal logs in the task details
116
+ - turning on urgency inheritance from dependant tasks and disabling blocked and blocking urgency coefficients (as recommended by Taskwarrior documentation)
117
+ - turning off urgency for waiting and scheduled tasks (taskcheck already take them into account)
118
+
119
+ Do you want to apply optional configurations? [y/N] """
120
+ )
121
+ if answer.lower() not in ["y", "yes"]:
122
+ configs = required_configs
123
+ else:
124
+ configs = required_configs + optional_configs
125
+
126
+ # Apply configurations using apply_config
127
+ try:
128
+ for key, value in configs:
129
+ apply_config(key, value)
130
+ print("Taskwarrior configurations have been applied successfully.")
131
+ except Exception as e:
132
+ print(f"Failed to apply configurations: {e}")
133
+
134
+ answer = input(
135
+ """
136
+ _________________________________________________________________________________________
137
+ Do you want to create a default config file for taskcheck? [y/N] """
138
+ )
139
+ if answer.lower() not in ["y", "yes"]:
140
+ return
141
+
142
+ config_dir.mkdir(parents=True, exist_ok=True)
143
+ config_file = config_dir / "taskcheck.toml"
144
+ if config_file.exists():
145
+ print(f"Config file already exists at {config_file}")
146
+ return
147
+ with open(config_file, "w") as f:
148
+ f.write(default_config)
149
+
150
+ print(f"Default config file created at {config_file}")
151
+
152
+
153
+ if __name__ == "__main__":
154
+ install()