@@ -84,9 +84,6 @@ class TaskWarriorException(Exception):
8484
8585class TaskWarrior (Backend ):
8686
87- VERSION_2_1_0 = '2.1.0'
88- VERSION_2_2_0 = '2.2.0'
89- VERSION_2_3_0 = '2.3.0'
9087 VERSION_2_4_0 = '2.4.0'
9188 VERSION_2_4_1 = '2.4.1'
9289 VERSION_2_4_2 = '2.4.2'
@@ -218,31 +215,17 @@ def format_depends(self, task):
218215 )
219216
220217 def format_description (self , task ):
221- # Task version older than 2.4.0 ignores first word of the
222- # task description if description: prefix is used
223- if self .version < self .VERSION_2_4_0 :
224- return task ._data ['description' ]
225- else :
226- return "description:'{0}'" .format (
227- task ._data ['description' ] or '' ,
228- )
218+ return "description:'{0}'" .format (
219+ task ._data ['description' ] or '' ,
220+ )
229221
230222 def convert_datetime_string (self , value ):
231-
232- if self .version >= self .VERSION_2_4_0 :
233- # For strings, use 'calc' to evaluate the string to datetime
234- # available since TW 2.4.0
235- args = value .split ()
236- result = self .execute_command (['calc' ] + args )
237- naive = datetime .datetime .strptime (result [0 ], DATE_FORMAT_CALC )
238- localized = local_zone .localize (naive )
239- else :
240- raise ValueError (
241- 'Provided value could not be converted to '
242- 'datetime, its type is not supported: {}'
243- .format (type (value )),
244- )
245-
223+ # For strings, use 'calc' to evaluate the string to datetime
224+ # available since TW 2.4.0
225+ args = value .split ()
226+ result = self .execute_command (['calc' ] + args )
227+ naive = datetime .datetime .strptime (result [0 ], DATE_FORMAT_CALC )
228+ localized = local_zone .localize (naive )
246229 return localized
247230
248231 @property
@@ -329,7 +312,7 @@ def get_task(self, uuid):
329312
330313 def filter_tasks (self , filter_obj ):
331314 self .enforce_recurrence ()
332- args = [ 'export' ] + filter_obj .get_filter_params ()
315+ args = filter_obj .get_filter_params () + [ "export" ]
333316 tasks = []
334317 for line in self .execute_command (args ):
335318 if line :
@@ -347,16 +330,19 @@ def save_task(self, task):
347330
348331 args = [task ['uuid' ], 'modify' ] if task .saved else ['add' ]
349332 args .extend (self ._get_modified_task_fields_as_args (task ))
350- output = self .execute_command (args )
333+ output = self .execute_command (
334+ args ,
335+ config_override = {'verbose' : 'new-uuid' }
336+ )
351337
352338 # Parse out the new ID, if the task is being added for the first time
353339 if not task .saved :
354340 id_lines = [l for l in output if l .startswith ('Created task ' )]
355341
356342 # Complain loudly if it seems that more tasks were created
357343 # Should not happen.
358- # Expected output: Created task 1 .
359- # Created task 1 (recurrence template).
344+ # Expected output: Created task bd23f69a-a078-48a4-ac11-afba0643eca9 .
345+ # Created task bd23f69a-a078-48a4-ac11-afba0643eca9 (recurrence template).
360346 if len (id_lines ) != 1 or len (id_lines [0 ].split (' ' )) not in (3 , 5 ):
361347 raise TaskWarriorException (
362348 'Unexpected output when creating '
@@ -366,11 +352,8 @@ def save_task(self, task):
366352 # Circumvent the ID storage, since ID is considered read-only
367353 identifier = id_lines [0 ].split (' ' )[2 ].rstrip ('.' )
368354
369- # Identifier can be either ID or UUID for completed tasks
370- try :
371- task ._data ['id' ] = int (identifier )
372- except ValueError :
373- task ._data ['uuid' ] = identifier
355+ # Identifier is UUID, because we used new-uuid verbosity override
356+ task ._data ['uuid' ] = identifier
374357
375358 # Refreshing is very important here, as not only modification time
376359 # is updated, but arbitrary attribute may have changed due hooks
@@ -387,10 +370,6 @@ def stop_task(self, task):
387370 self .execute_command ([task ['uuid' ], 'stop' ])
388371
389372 def complete_task (self , task ):
390- # Older versions of TW do not stop active task at completion
391- if self .version < self .VERSION_2_4_0 and task .active :
392- task .stop ()
393-
394373 self .execute_command ([task ['uuid' ], 'done' ])
395374
396375 def annotate_task (self , task , annotation ):
@@ -406,7 +385,11 @@ def refresh_task(self, task, after_save=False):
406385 # of newly saved tasks. Any other place in the code is fine
407386 # with using UUID only.
408387 args = [task ['uuid' ] or task ['id' ], 'export' ]
409- output = self .execute_command (args )
388+ output = self .execute_command (
389+ args ,
390+ # Supress GC, which can change ID numbers (undesirable for refresh)
391+ config_override = {'gc' : '0' }
392+ )
410393
411394 def valid (output ):
412395 return len (output ) == 1 and output [0 ].startswith ('{' )
@@ -427,8 +410,7 @@ def valid(output):
427410 for key , value in data .items ():
428411 taskfilter .add_filter_param (key , value )
429412
430- output = self .execute_command (['export' ] +
431- taskfilter .get_filter_params ())
413+ output = self .execute_command (taskfilter .get_filter_params () + ['export' ])
432414
433415 # If more than 1 task has been matched still, raise an exception
434416 if not valid (output ):
0 commit comments