improve code quality

This commit is contained in:
Nikos Kouremenos 2005-10-07 10:33:52 +00:00
parent 3e7627aa6d
commit 357c85a2ad
2 changed files with 11 additions and 11 deletions

View File

@ -139,13 +139,13 @@ def escape_for_pango_markup(string):
if gtk.pygtk_version >= (2, 8, 0) and gtk.gtk_version >= (2, 8, 0): if gtk.pygtk_version >= (2, 8, 0) and gtk.gtk_version >= (2, 8, 0):
escaped_str = gobject.markup_escape_text(string) escaped_str = gobject.markup_escape_text(string)
else: else:
escaped_str =xml.sax.saxutils.escape(string, {"'": ''', escaped_str = xml.sax.saxutils.escape(string, {"'": ''',
'"': '"'}) '"': '"'})
return escaped_str return escaped_str
def autodetect_browser_mailer(): def autodetect_browser_mailer():
#recognize the environment for appropriate browser/mailer # recognize the environment for appropriate browser/mailer
if os.path.isdir('/proc'): if os.path.isdir('/proc'):
# under Linux: checking if 'gnome-session' or # under Linux: checking if 'gnome-session' or
# 'startkde' programs were run before gajim, by # 'startkde' programs were run before gajim, by
@ -210,14 +210,14 @@ class TagInfoHandler(xml.sax.ContentHandler):
for attribute in attributes.getNames(): for attribute in attributes.getNames():
if attribute == 'jid': if attribute == 'jid':
jid = attributes.getValue(attribute) jid = attributes.getValue(attribute)
#We will get the port next time so we just set it 0 here # we will get the port next time so we just set it 0 here
self.servers.append([jid, 0]) self.servers.append([jid, 0])
elif name == self.tagname2: elif name == self.tagname2:
for attribute in attributes.getNames(): for attribute in attributes.getNames():
if attribute == 'port': if attribute == 'port':
port = attributes.getValue(attribute) port = attributes.getValue(attribute)
#We received the jid last time, so we now assign the port # we received the jid last time, so we now assign the port
#number to the last jid in the list # number to the last jid in the list
self.servers[-1][1] = port self.servers[-1][1] = port
def endElement(self, name): def endElement(self, name):
@ -230,10 +230,10 @@ def parse_server_xml(path_to_file):
return handler.servers return handler.servers
# handle exception if unable to open file # handle exception if unable to open file
except IOError, message: except IOError, message:
print "Error reading file:", message print >> sys.stderr, _('Error reading file:'), message
# handle exception parsing file # handle exception parsing file
except xml.sax.SAXParseException, message: except xml.sax.SAXParseException, message:
print "Error parsing file:", message print >> sys.stderr, _('Error parsing file:'), message
def set_unset_urgency_hint(window, unread_messages_no): def set_unset_urgency_hint(window, unread_messages_no):
'''sets/unsets urgency hint in window argument '''sets/unsets urgency hint in window argument
@ -285,7 +285,7 @@ def get_abspath_for_script(scriptname, want_type = False):
return path_to_script return path_to_script
def get_pixbuf_from_data(file_data): def get_pixbuf_from_data(file_data):
'''wants img data and returns gtk pixbuf''' '''wants img data and returns gtk.gdk.Pixbuf'''
pixbufloader = gtk.gdk.PixbufLoader() pixbufloader = gtk.gdk.PixbufLoader()
try: try:
pixbufloader.write(file_data) pixbufloader.write(file_data)

View File

@ -32,8 +32,8 @@ gtk.glade.textdomain(APP)
GTKGUI_GLADE = 'gtkgui.glade' GTKGUI_GLADE = 'gtkgui.glade'
class HistoryWindow: class HistoryWindow:
"""Class for bowser agent window: '''Class for bowser agent window:
to know the agents on the selected server""" to know the agents on the selected server'''
def on_history_window_destroy(self, widget): def on_history_window_destroy(self, widget):
del self.plugin.windows['logs'][self.jid] del self.plugin.windows['logs'][self.jid]
@ -119,7 +119,7 @@ class HistoryWindow:
self.latest_button.set_sensitive(False) self.latest_button.set_sensitive(False)
def new_line(self, date, type, data): def new_line(self, date, type, data):
"""write a new line""" '''write a new line'''
buff = self.history_buffer buff = self.history_buffer
start_iter = buff.get_start_iter() start_iter = buff.get_start_iter()
tim = time.strftime('[%x %X] ', time.localtime(float(date))) tim = time.strftime('[%x %X] ', time.localtime(float(date)))