[Pidgin] #8826: no default away message
Pidgin
trac at pidgin.im
Tue May 5 10:50:40 EDT 2015
#8826: no default away message
-------------------------+---------------------------
Reporter: zorkerz | Owner: deryni
Type: enhancement | Status: new
Milestone: | Component: unclassified
Version: 2.5.5 | Resolution:
Keywords: |
-------------------------+---------------------------
Comment (by tubaman):
I run this script before launching pidgin to remove the bogus status
messages:
{{{
#!/usr/bin/env python
"""Remove bogus statuses from pidgin's status.xml file"""
import sys
import os
import logging
import HTMLParser
import xml.etree.ElementTree as ET
def parse_status(status):
state, = [c.text for c in status if c.tag == 'state']
h = HTMLParser.HTMLParser()
try:
message, = [h.unescape(c.text) for c in status if c.tag ==
'message']
except ValueError:
message = None
return (state, message)
def is_bogus(status):
state, message = parse_status(status)
#if state == 'available' and message == "I'm not here right now":
if message == "I'm not here right now":
return True
def main(argv=None):
if argv is None:
argv = sys.argv
logging.basicConfig(level=logging.WARN)
status_path = os.path.join(os.environ['HOME'], '.purple',
'status.xml')
logging.debug("parsing %r", status_path)
tree = ET.parse(status_path)
statuses = tree.getroot()
assert statuses.tag == 'statuses'
assert statuses.attrib['version'] == '1.0'
statuses_seen = set()
for status in statuses:
logging.debug("checking %s", ET.tostring(status))
assert status.tag == 'status'
if parse_status(status) in statuses_seen:
logging.debug("is redundant")
statuses.remove(status)
elif is_bogus(status):
logging.debug("is bogus")
statuses.remove(status)
else:
logging.debug("not bogus or redundant")
statuses_seen.add(parse_status(status))
tree.write(status_path)
if __name__ == '__main__':
sys.exit(main())
}}}
--
Ticket URL: <https://developer.pidgin.im/ticket/8826#comment:15>
Pidgin <https://pidgin.im>
Pidgin
More information about the Tracker
mailing list