summaryrefslogtreecommitdiff
path: root/src/tabs/xmltab.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-10-14 15:51:30 +0200
committermathieui <mathieui@mathieui.net>2014-10-14 15:51:30 +0200
commit545ad1bd71e87a482b357f5b49a0898be73478d8 (patch)
treee513febd81f0c3d338b047f0672e5353e92534d4 /src/tabs/xmltab.py
parent37fe4be7ec35278f23c9f5c07607c3a14e6b6753 (diff)
parent088c6c6a0b46309d17c4b0ba5939a2dd200c7002 (diff)
downloadpoezio-545ad1bd71e87a482b357f5b49a0898be73478d8.tar.gz
poezio-545ad1bd71e87a482b357f5b49a0898be73478d8.tar.bz2
poezio-545ad1bd71e87a482b357f5b49a0898be73478d8.tar.xz
poezio-545ad1bd71e87a482b357f5b49a0898be73478d8.zip
Merge branch 'master' of git.poez.io:poezio into slix
Conflicts: src/core/handlers.py src/tabs/xmltab.py
Diffstat (limited to 'src/tabs/xmltab.py')
-rw-r--r--src/tabs/xmltab.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tabs/xmltab.py b/src/tabs/xmltab.py
index 7cbc9fb6..083e97c5 100644
--- a/src/tabs/xmltab.py
+++ b/src/tabs/xmltab.py
@@ -11,12 +11,14 @@ import logging
log = logging.getLogger(__name__)
import curses
+import os
from slixmpp.xmlstream import matcher
from slixmpp.xmlstream.handler import Callback
from . import Tab
import windows
+from xhtml import clean_text
class XMLTab(Tab):
def __init__(self):
@@ -45,6 +47,10 @@ class XMLTab(Tab):
usage=_('<xml mask>'),
desc=_('Show only the stanzas matching the given xml mask.'),
shortdesc=_('Filter by xml mask.'))
+ self.register_command('dump', self.command_dump,
+ usage=_('<filename>'),
+ desc=_('Writes the content of the XML buffer into a file.'),
+ shortdesc=_('Write in a file.'))
self.input = self.default_help_message
self.key_func['^T'] = self.close
self.key_func['^I'] = self.completion
@@ -111,6 +117,17 @@ class XMLTab(Tab):
self.filter = ''
self.refresh()
+ def command_dump(self, arg):
+ """/dump <filename>"""
+ xml = self.core.xml_buffer.messages[:]
+ text = '\n'.join(('%s %s' % (msg.str_time, clean_text(msg.txt)) for msg in xml))
+ filename = os.path.expandvars(os.path.expanduser(arg))
+ try:
+ with open(filename, 'w') as fd:
+ fd.write(text)
+ except Exception as e:
+ self.core.information('Could not write the XML dump: %s' % e, 'Error')
+
def on_slash(self):
"""
'/' is pressed, activate the input