How to use the jrnl.util.u function in jrnl

To help you get started, we’ve selected a few jrnl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jrnl-org / jrnl / jrnl / exporters.py View on Github external
def entry_to_xml(entry, doc=None):
    """Turns an entry into an XML representation.
    If doc is not given, it will return a full XML document.
    Otherwise, it will only return a new 'entry' elemtent for
    a given doc."""
    doc_el = doc or minidom.Document()
    entry_el = doc_el.createElement('entry')
    for key, value in entry_to_dict(entry).items():
        elem = doc_el.createElement(key)
        elem.appendChild(doc_el.createTextNode(u(value)))
        entry_el.appendChild(elem)
    if not doc:
        doc_el.appendChild(entry_el)
        return doc_el.toprettyxml()
    else:
        return entry_el
github jrnl-org / jrnl / jrnl / exporters.py View on Github external
def to_xml(journal):
    """Returns a XML representation of the Journal."""
    tags = get_tags_count(journal)
    doc = minidom.Document()
    xml = doc.createElement('journal')
    tags_el = doc.createElement('tags')
    entries_el = doc.createElement('entries')
    for tag in tags:
        tag_el = doc.createElement('tag')
        tag_el.setAttribute('name', tag[1])
        count_node = doc.createTextNode(u(tag[0]))
        tag.appendChild(count_node)
        tags_el.appendChild(tag)
    for entry in journal.entries:
        entries_el.appendChild(entry_to_xml(entry, doc))
    xml.appendChild(entries_el)
    xml.appendChild(tags_el)
    doc.appendChild(xml)
    return doc.toprettyxml()