Skip to content

Commit

Permalink
Initial work on task merge approach
Browse files Browse the repository at this point in the history
  • Loading branch information
kostajh committed Apr 8, 2013
1 parent fb9b7df commit 897f869
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
26 changes: 23 additions & 3 deletions bugwarrior/db.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
from twiggy import log
from taskw import TaskWarrior
from taskw import TaskWarrior, TaskWarriorExperimental
from bugwarrior.notifications import send_notification
from bugwarrior.config import asbool

import subprocess
import pprint

MARKUP = "(bw)"


def synchronize(issues, conf):
tw = TaskWarrior()
notify = (
'notifications' in conf.sections() and
asbool(conf.get('notifications', 'notifications', 'True'))
)

experimental = (
'general' in conf.sections() and
asbool(conf.get('general', 'experimental', 'True'))
)

if experimental is True:
# @TODO don't hardcode path to config filename.
tw = TaskWarriorExperimental(config_filename='~/.bugwarrior_taskrc')
else:
tw = TaskWarriorExperimental()

# Load info about the task database
tasks = tw.load_tasks()

is_bugwarrior_task = lambda task: \
task.get('description', '').startswith(MARKUP)

Expand Down Expand Up @@ -83,6 +95,14 @@ def synchronize(issues, conf):

tw.task_done(uuid=task['uuid'])

# Merge tasks with users local DB
if experimental is True:
# Call task merge from users local database
config = tw.load_config()
bwtask_data = "%s/" % config['data']['location']
subprocess.call(['task', 'rc.verbose=nothing', 'rc.merge.autopush=no', 'merge', bwtask_data])

# Send notifications
if notify:
send_notification(
dict(description="New: %d, Completed: %d" % (
Expand Down
6 changes: 3 additions & 3 deletions bugwarrior/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def _get_metadata(issue):
project = ''
if 'project' in issue:
project = "Project: " + issue['project']
if 'due' in issue:
due = "Due: " + datetime.datetime.fromtimestamp(
int(issue['due'])).strftime('%Y-%m-%d')
# if 'due' in issue:
# due = "Due: " + datetime.datetime.fromtimestamp(
# int(issue['due'])).strftime('%Y-%m-%d')
if 'tags' in issue:
tags = "Tags: " + ', '.join(issue['tags'])
if 'priority' in issue:
Expand Down

0 comments on commit 897f869

Please sign in to comment.