diff --git a/.gitignore b/.gitignore index 6d167a3..0d4bcd1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +taskrcdir/ *.ics ### Python # Byte-compiled / optimized / DLL files diff --git a/main.py b/main.py index 39ad890..a64e5c4 100644 --- a/main.py +++ b/main.py @@ -5,27 +5,20 @@ Github: https://github.com/chess-seventh Description: TaskKhalReschedulWarrior. """ +from taskw import TaskWarrior as TaskW -import configparser - -from constants import CONFIG_FILE -# from constants import DAY - -# from events import next_days from events import create_events -# from events import add_time from tasks import load_tasks -# from tasks import scheduled_tasks from tasks import overdue_tasks from tasks import not_date_tasks + from logger import logger from helpers import sort_task_urgency -# from helpers import execute -def main(task_config, khal_config): +def main(): """TaskKhalReschedulWarrior. :task_config: TaskWarrior configuration. @@ -35,16 +28,30 @@ def main(task_config, khal_config): """ # TODO: Khal logic # TODO: Set khal proper days - logger.debug(khal_config) - tasks = load_tasks(task_config) + task_war = TaskW(config_filename="./taskrcdir") + tw_config = task_war.load_config() + tw_config_location = tw_config['data']['location'] + tw_projects = tw_config['uda.trsw.projects'].split(',') + khal_location = tw_config['uda.calendar.location'] + khal_config = tw_config['uda.khal.config'] + + print(tw_projects) + print(khal_location) + print(khal_config) + return + + tasks = load_tasks(tw_config_location) tasks.sort(key=sort_task_urgency, reverse=True) # tasks_sched = scheduled_tasks(tasks) # events_sched = create_events(tasks_sched) nodates_tasks = overdue_tasks(tasks) + not_date_tasks(tasks) + for task in nodates_tasks: + if "lab" in task['project']: + print(task) - create_events(nodates_tasks, khal_config) + # create_events(nodates_tasks, khal_config) # execute(khal_config, cal_sundays) # execute(khal_config, cal_mondays) @@ -52,14 +59,4 @@ def main(task_config, khal_config): if __name__ == "__main__": - CONFIG = configparser.ConfigParser() - CONFIG.read(CONFIG_FILE) - TASK_CONF = list() - TASK_CONF.append(CONFIG['TaskConfig']['TaskDir']) - TASK_CONF.append(CONFIG['TaskConfig']['TaskProjects'].split(',')) - - KHAL_CONF = list() - # KHAL_CONF.append(CONFIG['KhalConfig']['KhalDir']) - KHAL_CONF.append(CONFIG['KhalConfig']['KhalCalendar']) - - main(task_config=TASK_CONF, khal_config=KHAL_CONF) + main() diff --git a/requirements.txt b/requirements.txt index 1cd3f5c..e3284de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,6 +14,7 @@ ics==0.4 idna==2.8 isort==4.3.21 khal==0.9.10 +kitchen==1.2.6 lazy-object-proxy==1.4.3 mccabe==0.6.1 Pygments==2.3.1 @@ -24,6 +25,7 @@ pyxdg==0.26 requests==2.21.0 six==1.14.0 tasklib==1.3.0 +taskw==1.2.0 typing==3.6.6 tzlocal==2.0.0 urllib3==1.24.2 diff --git a/tasks.py b/tasks.py index 4e4c6f4..7a0a342 100644 --- a/tasks.py +++ b/tasks.py @@ -11,6 +11,14 @@ from helpers import normalize_task_date +def load_tw_config(): + """ + Load TaskWarrior configuration to get the UDA. + """ + tw = TaskW() + return tw.load_config() + + def load_tasks(task_config): """Load tasks based on parsed config. :task_config: TaskWarrior configuration.