completion: Fix compatibility with taskwarrior 2.4.4

This commit is contained in:
Tomas Janousek 2020-12-26 12:43:07 +01:00 committed by Tomas Babej
parent 6cedc13b58
commit 12d363df5e
2 changed files with 14 additions and 5 deletions

View file

@ -1,6 +1,8 @@
from functools import reduce, wraps from functools import reduce, wraps
import re import re
from tasklib import TaskWarrior
from taskwiki import constants from taskwiki import constants
@ -53,6 +55,9 @@ class Completion():
@cached_property @cached_property
def _tags(self): def _tags(self):
if self.tw.version < TaskWarrior.VERSION_2_4_5:
return sorted(self.tw.execute_command(['_tags']))
else:
return sorted(set( return sorted(set(
tag tag
for tags in self.tw.execute_command(['_unique', 'tag']) for tags in self.tw.execute_command(['_unique', 'tag'])
@ -60,6 +65,9 @@ class Completion():
@cached_property @cached_property
def _projects(self): def _projects(self):
if self.tw.version < TaskWarrior.VERSION_2_4_5:
return sorted(self.tw.execute_command(['_projects']))
else:
return sorted(self.tw.execute_command(['_unique', 'project'])) return sorted(self.tw.execute_command(['_unique', 'project']))
def _complete_any(self, w): def _complete_any(self, w):

View file

@ -5,6 +5,7 @@ from tests.base import IntegrationTest
class FakeTW(): class FakeTW():
def __init__(self, projects=[], tags=[]): def __init__(self, projects=[], tags=[]):
self.version = '2.5.1'
self.projects = projects self.projects = projects
self.tags = tags self.tags = tags