code: def _convert_todo(self, p_todo):
          
  
          def _get_uid(p_todo):
              """
              Gets a unique ID from a todo item, stored by the ical tag. If the
              tag is not present, a random value is assigned to it and returned.
              """
  
              def generate_uid(p_length=4):
                  """
                  Generates a random string of the given length, used as
                  identifier.
                  """
                  return ''.join(
                      random.choice(string.ascii_letters + string.digits)
                      for i in range(p_length))
  
              uid = p_todo.tag_value('ical')
              if not uid:
                  uid = generate_uid()
                  p_todo.set_tag('ical', uid)
                  self.todolist.dirty = True
  
              return uid
  
          result = self.icalendar.Todo()
  
          # this should be called first, it may set the ical: tag and therefore
          # change the source() output.
          result['uid'] = _get_uid(p_todo)
  
          result['summary'] = self.icalendar.vText(p_todo.text())
          result['description'] = self.icalendar.vText(p_todo.source())
          result.add('priority', _convert_priority(p_todo.priority()))
  
          start = p_todo.start_date()
          if start:
              result.add('dtstart', start)
  
          due = p_todo.due_date()
          if due:
              result.add('due', due)
  
          created = p_todo.creation_date()
          if created:
              result.add('created', created)
  
          completed = p_todo.completion_date()
          if completed:
              completed = datetime.combine(completed, time(0, 0))
              result.add('completed', completed)
  
          return result
docs: Converts a Todo instance (Topydo) to an icalendar Todo instance.