fix pylint warnings

This commit is contained in:
Yann Leboulanger 2010-02-10 16:17:09 +01:00
parent 77e4e6e45f
commit c9ad0f5d7d
4 changed files with 53 additions and 44 deletions

View File

@ -1709,7 +1709,7 @@ class ChatControl(ChatControlBase):
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
id_ = menuitem.connect('activate', id_ = menuitem.connect('activate',
gtkgui_helpers.on_avatar_save_as_menuitem_activate, gtkgui_helpers.on_avatar_save_as_menuitem_activate,
self.contact.jid, self.account, self.contact.get_shown_name()) self.contact.jid, self.contact.get_shown_name())
self.handlers[id_] = menuitem self.handlers[id_] = menuitem
menu.append(menuitem) menu.append(menuitem)
menu.show_all() menu.show_all()

View File

@ -189,7 +189,8 @@ def get_default_font():
xdg_config_home = os.environ.get('XDG_CONFIG_HOME', '') xdg_config_home = os.environ.get('XDG_CONFIG_HOME', '')
if xdg_config_home == '': if xdg_config_home == '':
xdg_config_home = os.path.expanduser('~/.config') # default xdg_config_home = os.path.expanduser('~/.config') # default
xfce_config_file = os.path.join(xdg_config_home, 'xfce4/mcs_settings/gtk.xml') xfce_config_file = os.path.join(xdg_config_home,
'xfce4/mcs_settings/gtk.xml')
kde_config_file = os.path.expanduser('~/.kde/share/config/kdeglobals') kde_config_file = os.path.expanduser('~/.kde/share/config/kdeglobals')
@ -201,7 +202,8 @@ def get_default_font():
return line[start:line.find('"', start)].decode('utf-8') return line[start:line.find('"', start)].decode('utf-8')
except Exception: except Exception:
#we talk about file #we talk about file
print >> sys.stderr, _('Error: cannot open %s for reading') % xfce_config_file print >> sys.stderr, _('Error: cannot open %s for reading') % \
xfce_config_file
elif os.path.exists(kde_config_file): elif os.path.exists(kde_config_file):
try: try:
@ -216,7 +218,8 @@ def get_default_font():
return font_string.decode('utf-8') return font_string.decode('utf-8')
except Exception: except Exception:
#we talk about file #we talk about file
print >> sys.stderr, _('Error: cannot open %s for reading') % kde_config_file print >> sys.stderr, _('Error: cannot open %s for reading') % \
kde_config_file
return None return None
@ -261,7 +264,7 @@ def get_running_processes():
files = os.listdir('/proc') files = os.listdir('/proc')
# files that doesn't have only digits in names... # files that doesn't have only digits in names...
files = filter(str.isdigit, files) files = [f for f in files if f.isdigit()]
# files that aren't directories... # files that aren't directories...
files = [f for f in files if os.path.isdir('/proc/' + f)] files = [f for f in files if os.path.isdir('/proc/' + f)]
@ -275,7 +278,8 @@ def get_running_processes():
files = [f for f in files if os.path.islink('/proc/' + f + '/exe')] files = [f for f in files if os.path.islink('/proc/' + f + '/exe')]
# list of processes # list of processes
processes = [os.path.basename(os.readlink('/proc/' + f +'/exe')) for f in files] processes = [os.path.basename(os.readlink('/proc/' + f +'/exe')) for f \
in files]
return processes return processes
return [] return []
@ -314,7 +318,8 @@ class HashDigest:
def cleanID(self, id_): def cleanID(self, id_):
id_ = id_.strip().lower() id_ = id_.strip().lower()
for strip in (' :.-_'): id_ = id_.replace(strip, '') for strip in (' :.-_'):
id_ = id_.replace(strip, '')
return id_ return id_
def __eq__(self, other): def __eq__(self, other):
@ -436,7 +441,8 @@ def get_abspath_for_script(scriptname, want_type = False):
os.chmod(path_to_script, 0700) os.chmod(path_to_script, 0700)
except OSError: # do not traceback (could be a permission problem) except OSError: # do not traceback (could be a permission problem)
#we talk about a file here #we talk about a file here
s = _('Could not write to %s. Session Management support will not work') % path_to_script s = _('Could not write to %s. Session Management support will '
'not work') % path_to_script
print >> sys.stderr, s print >> sys.stderr, s
else: # normal user (not svn user) else: # normal user (not svn user)
@ -756,8 +762,10 @@ def possibly_set_gajim_as_xmpp_handler():
# setting for GNOME/Gconf # setting for GNOME/Gconf
client.set_bool('/desktop/gnome/url-handlers/xmpp/enabled', True) client.set_bool('/desktop/gnome/url-handlers/xmpp/enabled', True)
client.set_string('/desktop/gnome/url-handlers/xmpp/command', command) client.set_string('/desktop/gnome/url-handlers/xmpp/command',
client.set_bool('/desktop/gnome/url-handlers/xmpp/needs_terminal', False) command)
client.set_bool('/desktop/gnome/url-handlers/xmpp/needs_terminal',
False)
# setting for KDE # setting for KDE
if path_to_kde_file is not None: # user has run kde at least once if path_to_kde_file is not None: # user has run kde at least once
@ -780,7 +788,8 @@ Description=xmpp
''' % command) ''' % command)
f.close() f.close()
except IOError: except IOError:
log.debug("I/O Error writing settings to %s", repr(path_to_kde_file), exc_info=True) log.debug("I/O Error writing settings to %s",
repr(path_to_kde_file), exc_info=True)
else: # no gajim remote, stop ask user everytime else: # no gajim remote, stop ask user everytime
gajim.config.set('check_if_gajim_is_default', False) gajim.config.set('check_if_gajim_is_default', False)
@ -807,8 +816,8 @@ Description=xmpp
# xmpp: is currently handled by another program, so ask the user # xmpp: is currently handled by another program, so ask the user
pritext = _('Gajim is not the default Jabber client') pritext = _('Gajim is not the default Jabber client')
sectext = _('Would you like to make Gajim the default Jabber client?') sectext = _('Would you like to make Gajim the default Jabber client?')
checktext = _('Always check to see if Gajim is the default Jabber client ' checktext = _('Always check to see if Gajim is the default Jabber '
'on startup') 'client on startup')
def on_cancel(checked): def on_cancel(checked):
gajim.config.set('check_if_gajim_is_default', checked) gajim.config.set('check_if_gajim_is_default', checked)
dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, checktext, dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, checktext,
@ -849,12 +858,12 @@ def get_possible_button_event(event):
def destroy_widget(widget): def destroy_widget(widget):
widget.destroy() widget.destroy()
def on_avatar_save_as_menuitem_activate(widget, jid, account, default_name=''): def on_avatar_save_as_menuitem_activate(widget, jid, default_name=''):
def on_continue(response, file_path): def on_continue(response, file_path):
if response < 0: if response < 0:
return return
pixbuf = get_avatar_pixbuf_from_cache(jid) pixbuf = get_avatar_pixbuf_from_cache(jid)
path, extension = os.path.splitext(file_path) extension = os.path.splitext(file_path)[1]
if not extension: if not extension:
# Silently save as Jpeg image # Silently save as Jpeg image
image_format = 'jpeg' image_format = 'jpeg'
@ -875,8 +884,9 @@ def on_avatar_save_as_menuitem_activate(widget, jid, account, default_name=''):
def on_ok(file_path, pixbuf): def on_ok(file_path, pixbuf):
pixbuf.save(file_path, 'jpeg') pixbuf.save(file_path, 'jpeg')
dialogs.ConfirmationDialog(_('Extension not supported'), dialogs.ConfirmationDialog(_('Extension not supported'),
_('Image cannot be saved in %(type)s format. Save as %(new_filename)s?' _('Image cannot be saved in %(type)s format. Save as '
) % {'type': image_format, 'new_filename': new_file_path}, '%(new_filename)s?') % {'type': image_format,
'new_filename': new_file_path},
on_response_ok = (on_ok, new_file_path, pixbuf)) on_response_ok = (on_ok, new_file_path, pixbuf))
else: else:
dialog.destroy() dialog.destroy()
@ -888,10 +898,9 @@ def on_avatar_save_as_menuitem_activate(widget, jid, account, default_name=''):
# check if we have write permissions # check if we have write permissions
if not os.access(file_path, os.W_OK): if not os.access(file_path, os.W_OK):
file_name = os.path.basename(file_path) file_name = os.path.basename(file_path)
dialogs.ErrorDialog(_('Cannot overwrite existing file "%s"' % dialogs.ErrorDialog(_('Cannot overwrite existing file "%s"') % \
file_name), file_name, _('A file with this name already exists and you '
_('A file with this name already exists and you do not have ' 'do not have permission to overwrite it.'))
'permission to overwrite it.'))
return return
dialog2 = dialogs.FTOverwriteConfirmationDialog( dialog2 = dialogs.FTOverwriteConfirmationDialog(
_('This file already exists'), _('What do you want to do?'), _('This file already exists'), _('What do you want to do?'),
@ -902,8 +911,8 @@ def on_avatar_save_as_menuitem_activate(widget, jid, account, default_name=''):
dirname = os.path.dirname(file_path) dirname = os.path.dirname(file_path)
if not os.access(dirname, os.W_OK): if not os.access(dirname, os.W_OK):
dialogs.ErrorDialog(_('Directory "%s" is not writable') % \ dialogs.ErrorDialog(_('Directory "%s" is not writable') % \
dirname, _('You do not have permission to create files in this' dirname, _('You do not have permission to create files in '
' directory.')) 'this directory.'))
return return
on_continue(0, file_path) on_continue(0, file_path)
@ -1124,7 +1133,7 @@ def __label_size_allocate(widget, allocation):
# set wrap width to the pango.Layout of the labels ### # set wrap width to the pango.Layout of the labels ###
layout.set_width (allocation.width * pango.SCALE) layout.set_width (allocation.width * pango.SCALE)
lw, lh = layout.get_size () lh = layout.get_size()[1]
if lh_old != lh: if lh_old != lh:
widget.set_size_request (-1, lh / pango.SCALE) widget.set_size_request (-1, lh / pango.SCALE)

View File

@ -190,7 +190,7 @@ class ProfileWindow:
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
menuitem.connect('activate', menuitem.connect('activate',
gtkgui_helpers.on_avatar_save_as_menuitem_activate, gtkgui_helpers.on_avatar_save_as_menuitem_activate,
self.jid, self.account, nick) self.jid, nick)
menu.append(menuitem) menu.append(menuitem)
# show clear # show clear
menuitem = gtk.ImageMenuItem(gtk.STOCK_CLEAR) menuitem = gtk.ImageMenuItem(gtk.STOCK_CLEAR)

View File

@ -164,7 +164,7 @@ class VcardWindow:
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
menuitem.connect('activate', menuitem.connect('activate',
gtkgui_helpers.on_avatar_save_as_menuitem_activate, gtkgui_helpers.on_avatar_save_as_menuitem_activate,
self.contact.jid, self.account, self.contact.get_shown_name()) self.contact.jid, self.contact.get_shown_name())
menu.append(menuitem) menu.append(menuitem)
menu.connect('selection-done', lambda w:w.destroy()) menu.connect('selection-done', lambda w:w.destroy())
# show the menu # show the menu
@ -479,7 +479,7 @@ class ZeroconfVcardWindow:
menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS)
menuitem.connect('activate', menuitem.connect('activate',
gtkgui_helpers.on_avatar_save_as_menuitem_activate, gtkgui_helpers.on_avatar_save_as_menuitem_activate,
self.contact.jid, self.account, self.contact.get_shown_name()) self.contact.jid, self.contact.get_shown_name())
menu.append(menuitem) menu.append(menuitem)
menu.connect('selection-done', lambda w:w.destroy()) menu.connect('selection-done', lambda w:w.destroy())
# show the menu # show the menu