VimwikiTask: Further changes related to ShortUUUID being the only key

This commit is contained in:
Tomas Babej 2015-04-04 22:27:57 +02:00
parent c340a56c8f
commit a5b0aa85fb
2 changed files with 12 additions and 9 deletions

View file

@ -3,6 +3,8 @@ import vim # pylint: disable=F0401
import vwtask
import viewport
from tasklib.task import TaskWarrior
class WarriorStore(object):
"""
@ -83,8 +85,7 @@ class TaskCache(object):
def __setitem__(self, key, value):
# String keys refer to the Task objects
if type(key) in (str, unicode):
key = vwtask.ShortUUID(key)
if type(key) is vwtask.ShortUUID:
self.task_cache[key] = value
# Integer keys (line numbers) refer to the VimwikiTask objects
@ -148,8 +149,8 @@ class TaskCache(object):
# Select all tasks in the files that have UUIDs
uuids = [
t.uuid for t in self.vimwikitask_cache.values()
if t is not None and t.uuid is not None and t.warrior = tw
t.uuid.value for t in self.vimwikitask_cache.values()
if t is not None and t.uuid is not None and t.tw == tw
]
# If no task in the file contains UUID, we have no job here
@ -161,7 +162,7 @@ class TaskCache(object):
# Update each task in the cache
for task in tasks:
key = ShortUUID(task['uuid'], tw)
key = vwtask.ShortUUID(task['uuid'], tw)
self.task_cache[key] = task
def update_vwtasks_from_tasks(self):

View file

@ -28,7 +28,7 @@ class ViewPort(object):
"""
self.cache = cache
self.tw = cache.tw
self.tw = cache.warriors['default']
self.name = name
self.line_number = line_number
@ -146,8 +146,10 @@ class ViewPort(object):
# Find matching vimwikitasks in the self.tasks set
# There might be more if the viewport contained multiple
# representations of the same task
matching_vimwikitasks= [t for t in self.tasks
if t.uuid == task['uuid']]
matching_vimwikitasks= [
t for t in self.tasks
if t.uuid == vwtask.ShortUUID(task['uuid'], self.tw)
]
# Remove the tasks from viewport's set and from buffer
for vimwikitask in matching_vimwikitasks:
@ -162,7 +164,7 @@ class ViewPort(object):
added_at = self.line_number + len(self.tasks) + added_tasks
# Add the task object to cache
self.cache[task['uuid']] = task
self.cache[vwtask.ShortUUID(task['uuid'], self.tw)] = task
# Create the VimwikiTask
vimwikitask = vwtask.VimwikiTask.from_task(self.cache, task)