Add tags to json and xml exporters (#975)

* tag array for json
* add tags to entry in xml
* xml test
* json test
* black
* removed called
This commit is contained in:
eshrh 2020-06-13 14:58:35 -04:00 committed by GitHub
parent c1b93cf81b
commit be38cfa87a
4 changed files with 30 additions and 4 deletions

View file

@ -20,6 +20,7 @@ class JSONExporter(TextExporter):
"body": entry.body,
"date": entry.date.strftime("%Y-%m-%d"),
"time": entry.date.strftime("%H:%M"),
"tags": entry.tags,
"starred": entry.starred,
}
if hasattr(entry, "uuid"):

View file

@ -35,6 +35,11 @@ class XMLExporter(JSONExporter):
if hasattr(entry, "uuid"):
entry_el.setAttribute("uuid", entry.uuid)
entry_el.setAttribute("starred", entry.starred)
tags = entry.tags
for tag in tags:
tag_el = doc.createElement("tag")
tag_el.setAttribute("name", tag)
entry_el.appendChild(tag_el)
entry_el.appendChild(doc.createTextNode(entry.fulltext))
return entry_el