def save_task(self, task):
args = [task['<STR_LIT>'], '<STR_LIT>'] if task.saved else ['<STR_LIT>']<EOL>args.extend(self._get_modified_task_fields_as_args(task))<EOL>output = self.execute_command(args)<EOL>if not task.saved:<EOL><INDENT>id_lines = [l for l in output if l.startswith('<STR_LIT>')]<EOL>if len(id_lines) != <NUM_LIT:1> or len(id_lines[<NUM_LIT:0>].split('<STR_LIT:U+0020>')) not in (<NUM_LIT:3>, <NUM_LIT:5>):<EOL><INDENT>raise TaskWarriorException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % '<STR_LIT:\n>'.join(id_lines),<EOL>)<EOL><DEDENT>identifier = id_lines[<NUM_LIT:0>].split('<STR_LIT:U+0020>')[<NUM_LIT:2>].rstrip('<STR_LIT:.>')<EOL>try:<EOL><INDENT>task._data['<STR_LIT:id>'] = int(identifier)<EOL><DEDENT>except ValueError:<EOL><INDENT>task._data['<STR_LIT>'] = identifier<EOL><DEDENT><DEDENT>task.refresh(after_save=True)<EOL>
Save a task into TaskWarrior database using add/modify call