How to use the tasklib.TaskWarrior function in tasklib

To help you get started, we’ve selected a few tasklib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tbabej / taskwiki / tests / base.py View on Github external
def generate_data(self):
        self.dir = tempfile.mkdtemp(dir='/tmp/')

        # Create an actual taskrc file where we can write later
        self.taskrc_path = os.path.join(self.dir, "taskrc")
        with open(self.taskrc_path, 'w') as f:
            f.write("#testing taskrc\n")

        self.tw = TaskWarrior(
            data_location=self.dir,
            taskrc_location=self.taskrc_path
        )

        self.tasks = [Task(self.tw, **task_kwargs)
                      for task_kwargs in self.__class__.tasks]

        for task in self.tasks:
            task.save()
github tbabej / taskwiki / tests / base.py View on Github external
def generate_data(self):
        super(MultipleSourceTest, self).generate_data()

        self.extra_dir = tempfile.mkdtemp(dir='/tmp/')

        self.extra_tw = TaskWarrior(
            data_location=self.extra_dir,
            taskrc_location='/'
        )

        extra_tasks = [Task(self.extra_tw, **task_kwargs)
                       for task_kwargs in self.extra_tasks]

        self.extra_tasks = extra_tasks
        for task in self.extra_tasks:
            task.save()
github scottkosty / vit / application-ppt.py View on Github external
def hot_report(event):
  app = event.app
  tw = TaskWarrior()
  tasks = tw.tasks.filter('+PENDING', 'priority:H')
  pp.pprint("HOT")
  app.exit()
  init_app(tasks)
github liloman / pomodoroTasks2 / pomodorotasks / daemon.py View on Github external
def __init__(self, rc = '~/.task'):
        self.tw = TaskWarrior(data_location=rc, create=True)
        try:
            name = dbus.service.BusName(self.bus_name, bus=dbus.SessionBus(),do_not_queue=True, replace_existing=False, allow_replacement=False )
            dbus.service.Object.__init__(self, name, '/daemon')
        except dbus.exceptions.NameExistsException:
            print("Daemon is already running.")
            sys.exit(0)
github tbabej / task.shift-recurrence / pirate_add_shift_recurrence.py View on Github external
from tasklib import TaskWarrior

time_attributes = ('wait', 'scheduled')

def is_new_local_recurrence_child_task(task):
    # Do not affect tasks not spun by recurrence
    if not task['parent']:
        return False

    # Newly created recurrence tasks actually have
    # modified field copied from the parent, thus
    # older than entry field (until their ID is generated)
    if (task['modified'] - task['entry']).total_seconds() < 0:
        return True

tw = TaskWarrior(data_location=os.path.dirname(os.path.dirname(sys.argv[0])))
tw.overrides.update(dict(recurrence="no", hooks="no"))

def hook_shift_recurrence(task):
    if is_new_local_recurrence_child_task(task):
        parent = tw.tasks.get(uuid=task['parent']['uuid'])
        parent_due_shift = task['due'] - parent['due']
        for attr in time_attributes:
            if parent[attr]:
                task[attr] = parent[attr] + parent_due_shift
github scottkosty / vit / application-asciimatics.py View on Github external
from asciimatics.widgets import Frame, MultiColumnListBox, Layout, Divider, Text, \
    Button, TextBox, Widget, Label
from asciimatics.scene import Scene
from asciimatics.screen import Screen
from asciimatics.exceptions import ResizeScreenError, NextScene, StopApplication
import sys
import re
from functools import partial
from tasklib import TaskWarrior
tw = TaskWarrior()

def get_app_width():
  return 80

def task_date(task, attr, fmt='%Y-%m-%d'):
  try:
    return task[attr].strftime(fmt)
  except AttributeError:
    return ''

def wrap_line(text, length=40):
  output = ''
  for x in text.splitlines():
    output += '\n'.join(line.strip() for line in re.findall(r".{1,%s}(?:\s+|$)" % length, x))
  return output
github liloman / pomodoroTasks2 / pomodorotasks / systray.py View on Github external
def __init__(self, rc = '~/.task'):
        self.tw = TaskWarrior(data_location=rc, create=True)
        self.status_icon = Gtk.StatusIcon()
        self.status_icon.set_from_file("images/iconStarted-0.png")
        self.status_icon.connect("popup-menu", self.right_click_event)
        self.status_icon.connect("activate", self.left_click_event)
        # systray daemon
        name = dbus.service.BusName(self.bus_name, bus=dbus.SessionBus(),do_not_queue=True, replace_existing=False, allow_replacement=False )
        dbus.service.Object.__init__(self, name, '/systray')
        # client for daemon
        bus = dbus.SessionBus(private = True)
        daemon_client = bus.get_object('org.liloman.pomodoro', "/daemon")
        self.interface = dbus.Interface(daemon_client, "org.liloman.pomodoroInterface")
github scottkosty / vit / vit / task.py View on Github external
def __init__(self, task_config, reports, report=None, data_location=None):

        if not data_location:
            data_location = task_config.subtree('data.location')
        self.data_location = os.path.expanduser(data_location)
        self.tw = tasklib.TaskWarrior(self.data_location)
        self.reports = reports
        self.report = report
        self.tasks = []
        if report:
            self.update_report(report)
github liloman / pomodoroTasks2 / pomodorotasks / do_timeout.py View on Github external
def __init__(self):
        self.tw = TaskWarrior()
        builder.add_from_file("gui/timeout.glade")
        self.wTimeout     = builder.get_object("wTimeout")
        self.pbTimeout    = builder.get_object("pbTimeout")
        self.wContinue    = builder.get_object("wContinue")
        self.lsbReminders = builder.get_object("lsbReminders")
        self.bus = dbus.SessionBus()
        self.session_bus = self.bus.get_object('org.liloman.pomodoro', "/daemon")
        self.interface = dbus.Interface(self.session_bus, "org.liloman.pomodoroInterface")

        ################
        #  Set events  #
        ################

        self.btYes = builder.get_object("btYes")
        self.btYes.connect("clicked",self.onYesPressed)
        self.btNo = builder.get_object("btNo")