def to_task(self, vtodo, project=None, uuid=None):
task = {}<EOL>if project and project != '<STR_LIT>' and project != '<STR_LIT>':<EOL><INDENT>task['<STR_LIT>'] = project<EOL><DEDENT>if uuid:<EOL><INDENT>task['<STR_LIT>'] = uuid<EOL><DEDENT>if hasattr(vtodo, '<STR_LIT>'):<EOL><INDENT>task['<STR_LIT>'] = self._tw_timestamp(vtodo.dtstamp.value)<EOL><DEDENT>if hasattr(vtodo, '<STR_LIT>'):<EOL><INDENT>task['<STR_LIT>'] = self._tw_timestamp(vtodo.last_modified.value)<EOL><DEDENT>if hasattr(vtodo, '<STR_LIT>'):<EOL><INDENT>task['<STR_LIT:start>'] = self._tw_timestamp(vtodo.dtstart.value)<EOL><DEDENT>if hasattr(vtodo, '<STR_LIT>'):<EOL><INDENT>task['<STR_LIT>'] = self._tw_timestamp(vtodo.due.value)<EOL><DEDENT>if hasattr(vtodo, '<STR_LIT>'):<EOL><INDENT>task['<STR_LIT:end>'] = self._tw_timestamp(vtodo.completed.value)<EOL><DEDENT>task['<STR_LIT:description>'] = vtodo.summary.value<EOL>if hasattr(vtodo, '<STR_LIT>'):<EOL><INDENT>task['<STR_LIT>'] = vtodo.categories.value<EOL><DEDENT>if hasattr(vtodo, '<STR_LIT>'):<EOL><INDENT>priority = int(vtodo.priority.value)<EOL>if priority < <NUM_LIT:3>:<EOL><INDENT>task['<STR_LIT>'] = '<STR_LIT:H>'<EOL><DEDENT>elif <NUM_LIT:3> < priority < <NUM_LIT:7>:<EOL><INDENT>task['<STR_LIT>'] = '<STR_LIT:M>'<EOL><DEDENT>else:<EOL><INDENT>task['<STR_LIT>'] = '<STR_LIT:L>'<EOL><DEDENT><DEDENT>if hasattr(vtodo, '<STR_LIT:description>'):<EOL><INDENT>task['<STR_LIT>'] = []<EOL>for delta, comment in enumerate(vtodo.description.value.split('<STR_LIT:\n>')):<EOL><INDENT>stamp = self._tw_timestamp(vtodo.dtstamp.value + timedelta(seconds=delta))<EOL>if uuid in self._tasks.get(project, {}) and '<STR_LIT>' in self._tasks[project][uuid]:<EOL><INDENT>for annotation in self._tasks[project][uuid]['<STR_LIT>']:<EOL><INDENT>if annotation['<STR_LIT:description>'] == comment:<EOL><INDENT>stamp = annotation['<STR_LIT>']<EOL>break<EOL><DEDENT><DEDENT><DEDENT>task['<STR_LIT>'].append({'<STR_LIT>': stamp, '<STR_LIT:description>': comment})<EOL><DEDENT><DEDENT>if hasattr(vtodo, '<STR_LIT:status>'):<EOL><INDENT>if vtodo.status.value == '<STR_LIT>':<EOL><INDENT>task['<STR_LIT:status>'] = '<STR_LIT>'<EOL>if '<STR_LIT:start>' not in task:<EOL><INDENT>task['<STR_LIT:start>'] = self._tw_timestamp(vtodo.dtstamp.value)<EOL><DEDENT><DEDENT>elif vtodo.status.value == '<STR_LIT>':<EOL><INDENT>task['<STR_LIT:status>'] = '<STR_LIT>'<EOL><DEDENT>elif vtodo.status.value == '<STR_LIT>':<EOL><INDENT>task['<STR_LIT:status>'] = '<STR_LIT>'<EOL>if '<STR_LIT:end>' not in task:<EOL><INDENT>task['<STR_LIT:end>'] = self._tw_timestamp(vtodo.dtstamp.value)<EOL><DEDENT><DEDENT>elif vtodo.status.value == '<STR_LIT>':<EOL><INDENT>task['<STR_LIT:status>'] = '<STR_LIT>'<EOL>if '<STR_LIT:end>' not in task:<EOL><INDENT>task['<STR_LIT:end>'] = self._tw_timestamp(vtodo.dtstamp.value)<EOL><DEDENT><DEDENT><DEDENT>json = dumps(task, separators=('<STR_LIT:U+002C>', '<STR_LIT::>'), sort_keys=True)<EOL>with self._lock:<EOL><INDENT>p = run(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'.format(**locals()), '<STR_LIT>', '<STR_LIT:->'], input=json, encoding='<STR_LIT:utf-8>', stdout=PIPE)<EOL><DEDENT>uuid = findall('<STR_LIT>', p.stdout)[<NUM_LIT:0>]<EOL>self._update()<EOL>return self._gen_uid(uuid)<EOL>
Add or modify a task from vTodo to Taskwarrior
        vtodo -- the vTodo to add
        project -- the project to add (see get_filesnames() as well)
        uuid -- the UID of the task in Taskwarrior