Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
taskrcdir/
*.ics
### Python
# Byte-compiled / optimized / DLL files
Expand Down
45 changes: 21 additions & 24 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -35,31 +28,35 @@ 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)
# execute(khal_config, cal_wednesdays)


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()
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down