def addtask(doc, ze_id, title, text, tags, childs):
    t_xml = doc.createElement("task")
    t_xml.setAttribute("id", ze_id)
    t_xml.setAttribute("status", "Active")

    tagsWithPrefix = map(lambda x: "@"+x, tags)
    t_xml.setAttribute("tags", ",".join(tagsWithPrefix))

    cleanxml.addTextNode(doc, t_xml, "title", title)
    for c in childs:
        cleanxml.addTextNode(doc, t_xml, "subtask", c)
    cleanxml.addTextNode(doc, t_xml, "content", text)
    return t_xml
def addtask(doc, ze_id, title, text, children):
    """Initialize GTG tasks in order to display them at first run."""
    t_xml = doc.createElement("task")
    t_xml.setAttribute("id", ze_id)
    t_xml.setAttribute("status", "Active")

    tags = extract_tags_from_text(text)
    t_xml.setAttribute("tags", ",".join(tags))

    cleanxml.addTextNode(doc, t_xml, "title", title)
    for child in children:
        cleanxml.addTextNode(doc, t_xml, "subtask", child)
    cleanxml.addTextNode(doc, t_xml, "content", text)
    return t_xml
Example #3
0
def addtask(doc, ze_id, title, text, children):
    """Initialize GTG tasks in order to display them at first run."""
    t_xml = doc.createElement("task")
    t_xml.setAttribute("id", ze_id)
    t_xml.setAttribute("status", "Active")

    tags = extract_tags_from_text(text)
    t_xml.setAttribute("tags", ",".join(tags))

    cleanxml.addTextNode(doc, t_xml, "title", title)
    for child in children:
        cleanxml.addTextNode(doc, t_xml, "subtask", child)
    cleanxml.addTextNode(doc, t_xml, "content", text)
    return t_xml
Example #4
0
def task_to_xml(doc, task):
    t_xml = doc.createElement("task")
    t_xml.setAttribute("id", task.get_id())
    t_xml.setAttribute("status", task.get_status())
    t_xml.setAttribute("uuid", task.get_uuid())
    tags_str = ""
    for tag in task.get_tags_name():
        tags_str = tags_str + saxutils.escape(str(tag)) + ","
    t_xml.setAttribute("tags", tags_str[:-1])
    cleanxml.addTextNode(doc, t_xml, "title", task.get_title())
    cleanxml.addTextNode(doc, t_xml, "addeddate", task.get_added_date_string())
    cleanxml.addTextNode(doc, t_xml, "duedate", task.get_due_date().xml_str())
    cleanxml.addTextNode(doc, t_xml, "modified", task.get_modified_string())
    cleanxml.addTextNode(doc, t_xml, "startdate",
                         task.get_start_date().xml_str())
    cleanxml.addTextNode(doc, t_xml, "donedate",
                         task.get_closed_date().xml_str())
    childs = task.get_children()
    for c in childs:
        cleanxml.addTextNode(doc, t_xml, "subtask", c)
    for a in task.attributes:
        namespace, key = a
        content = task.attributes[a]
        element = doc.createElement('attribute')
        element.setAttribute("namespace", namespace)
        element.setAttribute("key", key)
        element.appendChild(doc.createTextNode(content))
        t_xml.appendChild(element)
    tex = task.get_text()
    if tex:
        # We take the xml text and convert it to a string
        # but without the "<content />"
        element = minidom.parseString(tex)
        temp = element.firstChild.toxml().partition("<content>")[2]

        desc = temp.partition("</content>")[0]
        # t_xml.appendChild(element.firstChild)
        cleanxml.addTextNode(doc, t_xml, "content", desc)
    # self.__write_textnode(doc,t_xml,"content",t.get_text())

    # REMOTE TASK IDS
    remote_ids_element = doc.createElement("task-remote-ids")
    t_xml.appendChild(remote_ids_element)
    remote_ids_dict = task.get_remote_ids()
    for backend_id, task_id in remote_ids_dict.items():
        backend_element = doc.createElement('backend')
        remote_ids_element.appendChild(backend_element)
        backend_element.appendChild(doc.createTextNode(backend_id))
        task_element = doc.createElement('task-id')
        backend_element.appendChild(task_element)
        task_element.appendChild(doc.createTextNode(task_id))

    return t_xml
def task_to_xml(doc, task):
    # print "Task to XML called"
    t_xml = doc.createElement("task")
    t_xml.setAttribute("id", task.get_id())
    t_xml.setAttribute("status", task.get_status())
    t_xml.setAttribute("uuid", task.get_uuid())
    tags_str = ""
    for tag in task.get_tags_name():
        tags_str = tags_str + saxutils.escape(str(tag)) + ","
    t_xml.setAttribute("tags", tags_str[:-1])
    cleanxml.addTextNode(doc, t_xml, "title", task.get_title())
    cleanxml.addTextNode(doc, t_xml, "duedate", task.get_due_date().xml_str())
    cleanxml.addTextNode(doc, t_xml, "modified", task.get_modified_string())
    cleanxml.addTextNode(doc, t_xml, "startdate", task.get_start_date().xml_str())
    cleanxml.addTextNode(doc, t_xml, "donedate", task.get_closed_date().xml_str())
    childs = task.get_children()
    for c in childs:
        cleanxml.addTextNode(doc, t_xml, "subtask", c)
    for a in task.attributes:
        namespace, key = a
        content = task.attributes[a]
        element = doc.createElement("attribute")
        element.setAttribute("namespace", namespace)
        element.setAttribute("key", key)
        element.appendChild(doc.createTextNode(content))
        t_xml.appendChild(element)
    tex = task.get_text()
    if tex:
        # We take the xml text and convert it to a string
        # but without the "<content />"
        element = minidom.parseString(tex)
        temp = element.firstChild.toxml().partition("<content>")[2]

        desc = temp.partition("</content>")[0]
        # t_xml.appendChild(element.firstChild)
        cleanxml.addTextNode(doc, t_xml, "content", desc)
    # self.__write_textnode(doc,t_xml,"content",t.get_text())

    # REMOTE TASK IDS
    remote_ids_element = doc.createElement("task-remote-ids")
    t_xml.appendChild(remote_ids_element)
    remote_ids_dict = task.get_remote_ids()
    for backend_id, task_id in remote_ids_dict.iteritems():
        # print "TASK2XML - backend id = " + backend_id + " task id = " + task_id
        backend_element = doc.createElement("backend")
        remote_ids_element.appendChild(backend_element)
        backend_element.appendChild(doc.createTextNode(backend_id))
        task_element = doc.createElement("task-id")
        backend_element.appendChild(task_element)
        task_element.appendChild(doc.createTextNode(task_id))

    return t_xml