tools-life / taskwiki

Proper project management with Taskwarrior in vim.
Other
827 stars 93 forks source link

Allow custom priorities #275

Open nkakouros opened 4 years ago

nkakouros commented 4 years ago

In the taskrc file, one can have:

uda.priority.values = H,M,,L,0
urgency.uda.priority.H.coefficient=20
urgency.uda.priority..coefficient=1.8
urgency.uda.priority.L.coefficient=-1
urgency.uda.priority.0.coefficient=-100

This works fine with task on the cli. Only thing not working is bash completion for the 0 priority.

In taskwiki, if I try to modify a task and assign 0 priority to it, I get:

Error invoking 'python_execute' on channel 3 (python3-script-host):                                                                                                                                                                          
Traceback (most recent call last):                                                                                                                                                                                                           
  File "<string>", line 1, in <module>                                                                                                                                                                                                       
  File "/home/nikos/.local/share/nvim/plugged/taskwiki/taskwiki/errors.py", line 26, in wrapped_function                                                                                                                                     
    original_function(*args, **kwargs)                                                                                                                                                                                                       
  File "/home/nikos/.local/share/nvim/plugged/taskwiki/taskwiki/main.py", line 222, in modify                                                                                                                                                
    cache().update_vwtasks_in_buffer()                                                                                                                                                                                                       
  File "/home/nikos/.local/share/nvim/plugged/taskwiki/taskwiki/cache.py", line 202, in update_vwtasks_in_buffer                                                                                                                             
    task.update_in_buffer()                                                                                                                                                                                                                  
  File "/home/nikos/.local/share/nvim/plugged/taskwiki/taskwiki/vwtask.py", line 321, in update_in_buffer                                                                                                                                    
    self.cache.buffer[self['line_number']] = str(self)                                                                                                                                                                                       
  File "/home/nikos/.local/share/nvim/plugged/taskwiki/taskwiki/vwtask.py", line 338, in __str__                                                                                                                                             
    ' ' + '!' * self.priority_from_tw_format if self['priority'] else '',                                                                                                                                                                    
  File "/home/nikos/.local/share/nvim/plugged/taskwiki/taskwiki/vwtask.py", line 244, in priority_from_tw_format                                                                                                                             
    return convert_priority_from_tw_format(self.task['priority'])                                                                                                                                                                            
  File "/home/nikos/.local/share/nvim/plugged/taskwiki/taskwiki/vwtask.py", line 15, in convert_priority_from_tw_format                                                                                                                      
    return {None: None, 'L': 1, 'M': 2, 'H': 3}[priority]                                                                                                                                                                                    
KeyError: '0'                                                                                                                                                                                                                                

The dict with the priorities should not be hardcoded, but read from the taskrc.

sdondley commented 2 years ago

I'm getting the same errors. I have a different system for my priorities than the author:

urgency.user.tag.qst.coefficient=8.0
urgency.user.tag.qsn.coefficient=8.0
urgency.user.tag.q.coefficient=8.0
urgency.blocking.coefficient=0.0
uda.priority.values=U,H,M,,L

urgency.uda.priority.U.coefficient=10.0
urgency.uda.priority.H.coefficient=6.0
urgency.uda.priority.M.coefficient=3.9
urgency.uda.priority.L.coefficient=-5.0

I looked at the patch provided in #304 but that seems to hard code in the priorities the author uses, AFAICT. What can I do to resolve this?