def __init__(self, factory, db=None, **kwargs): self._db = db or TaskWarrior(config_filename=kwargs['config']) self._factory = factory
import argparse from taskw import TaskWarrior URL = 'https://habitica.com/api/v3' if len(sys.argv) == 1: print "The Habitica hook does not work with TaskWarrior API v1, please upgrade to Taskwarrior 2.4.3 or higher" sys.exit(0) if not sys.argv[1] == "api:2": print "The Habitica hook only supports TaskWarrior API v2 at this time" sys.exit(0) configarg = sys.argv[4] configfile = configarg[3:] w = TaskWarrior(config_filename=configfile) config = w.load_config() API_KEY = config['habitica']['api_key'] API_USER = config['habitica']['api_user'] headers = { 'Content-Type' : 'application/json', 'x-api-user' : API_USER, 'x-api-key' : API_KEY } def main(): jsonTask = json.loads(sys.stdin.readline()) id = pushTask(jsonTask) if not id == "":
def get_tw() -> TaskWarrior: return TaskWarrior(config_overrides={'uda': _UDA}, marshal=True)
#from workdays import workdays # Under BSD license, so not included. from taskw import TaskWarrior WORKING_HRS_PER_DY = 8 WORKING_DAYS_PER_WK = 5 HOLIDAYS = [] NUM_TRIALS = 1000 # Number of trials for Monte Carlo Sim UDA_VELOCITY_KEY = 'velocity' # type: "number" UDA_ESTIMATED_KEY = 'estimatedtime' # type: duration UDA_ACTUAL_KEY = 'totalactivetime' # type: duration DISPLAY_WIDTH = 80 w = TaskWarrior() config = w.load_config() if UDA_ESTIMATED_KEY not in config['uda']: error('Missing UDA for estimated duration. Please follow setup procedures.') if UDA_ACTUAL_KEY not in config['uda']: error('Missing UDA for total active time in config. Please follow setup procedures.') def update_velocities(taskw, filters=''): "Loads velocities from taskwarrior instance, but saves values in taskwarrior UDA." # Same as 'load_velocities' pass def load_velocities(taskw, filters=''): "Loads velocities from taskwarrior instance without changing values." tasks = taskw.load_tasks('completed') tasks = tasks['completed']
def find_taskwarrior_from_azure_devops_id(work_item_id, task_list): return [t for t in task_list if t['description'].startswith(str(work_item_id))] def format_description(desc, tag_list): for keyword, tag in keyword_tag_replace_map.items(): desc, count = re.subn(r'[/\s[]*\b' + keyword + r'\b[]/\s]*', '', desc, flags=re.IGNORECASE) if count and tag: tag_list.append(tag) return desc if len(desc) <= max_description_length else f"{desc[:max_description_length]}..." # Task Warrior tasks load. task_warrior = TaskWarrior() print(f'Loading "{project}" Task warriors pending tasks ...') tw_tasks = get_taskwarrior_tasks(project.lower()) print(f'Found {len(tw_tasks)} tasks.') # Azure Devops current sprint's tasks load. print(f'Loading "{project}" Azure Devops work items ...') work_items = get_azure_devops_work_items(project, current_sprint, assignee) print(f'Found {len(work_items)} work items.') for work_item in work_items: # Checks if there is already a time warrior task for this Azure Devops item. existing_tw = find_taskwarrior_from_azure_devops_id(work_item['id'], tw_tasks) if existing_tw:
def __init__(self, config=None): if config is not None: self.w = TaskWarrior(config_filename=config) else: self.w = TaskWarrior() self.refresh_tasks()
def get_taskwarrior_instance(): return TaskWarrior(marshal=True)
return utils.parse_recur(due) except errors.UnsupportedRecurrence: io.error("Unsupported recurrence: '%s'. Please enter a valid value" % due['string']) return io.prompt( 'Set recurrence (todoist style)', default='', value_proc=validation.validate_recur, ) """ Entrypoint """ if __name__ == '__main__': is_help_cmd = '-h' in sys.argv or '--help' in sys.argv todoist_api_key = os.getenv('TODOIST_API_KEY') if todoist_api_key is None and not is_help_cmd: io.error( 'TODOIST_API_KEY environment variable not specified. Exiting.') exit(1) todoist = TodoistAPI(todoist_api_key, cache=TODOIST_CACHE) # Create the TaskWarrior client, overriding config to # create a `todoist_id` field which we'll use to # prevent duplicates taskwarrior = TaskWarrior(config_overrides={ 'uda.todoist_id.type': 'string', }) cli()
task.get("urgency"), task.get("entry").date(), task.get("due").date() if task.get("due") else "", task.get("end").date() if task.get("end") else "", task.get("project", " ").strip(), ",".join(task.get("tags", [])), task.get("description").strip(), task.get("jira", ""), ]) print(table) if __name__ == "__main__": # TODO: Wrap this in a main() method. task_client = TaskWarrior(marshal=True) today = date.today() yesterday = date.today() + relativedelta(days=-1) print(f"Daily Standup Report for {today}") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("") print("Yesterday's Completed Tasks") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("") completed_tasks = get_completed_tasks(task_client=task_client, start_date=yesterday, end_date=today) print_task_table(completed_tasks) overdue_tasks = filter_tasks(