diff options
Diffstat (limited to 'desktop/empathy-xml2txt.py')
-rwxr-xr-x | desktop/empathy-xml2txt.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/desktop/empathy-xml2txt.py b/desktop/empathy-xml2txt.py new file mode 100755 index 0000000..9c6a7a0 --- /dev/null +++ b/desktop/empathy-xml2txt.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- + +import sys +from lxml import etree + +def empathy_xml2txt(infile, outfile): + xmlparser = etree.XMLParser(encoding = 'UTF-8') + xmltree = etree.parse(infile, xmlparser) + xmlroot = xmltree.getroot() + for msg in xmlroot.iter(): + if msg.tag == "message": + outfile.write("{} <{:^12}> {}\n".format( + msg.get('time').replace('T', ' '), + msg.get('id'), + msg.text.encode('UTF-8'))) + +if __name__ == "__main__": + for i in sys.argv[1:]: + empathy_xml2txt(i, sys.stdout) |