[PATCH] avoid duplicate do_nothing() method definition
- From: Vincent Legoll <vincent legoll gmail com>
- To: meld-list gnome org
- Subject: [PATCH] avoid duplicate do_nothing() method definition
- Date: Sun, 15 Feb 2009 13:49:38 +0100
in historyentry.py, factorize code to avoid duplicated method definitions
--
Vincent Legoll
Index: historyentry.py
===================================================================
--- historyentry.py (révision 1153)
+++ historyentry.py (copie de travail)
@@ -196,17 +196,19 @@
history_id = gobject.property(get_history_id, __set_history_id, type=str)
max_saved = gobject.property(get_history_length, set_history_length, type=int)
+def setDoNothingHandlers(instance, *methodNames):
+
+ def do_nothing(self):
+ return
+
+ for methodName in methodNames:
+ setattr(instance, methodName, do_nothing)
+
try:
import gconf
except ImportError:
- def do_nothing(self):
- return
+ setDoNothingHandlers(HistoryEntry, '_save_history', '_load_history', '_get_gconf_client')
- for m in ('_save_history', '_load_history', '_get_gconf_client'):
- setattr(HistoryEntry, m, do_nothing)
-
-
-
def _expand_filename(filename, default_dir):
if not filename:
return ""
@@ -474,8 +476,4 @@
try:
import gnomevfs
except ImportError:
- def do_nothing(self):
- return
-
- setattr(HistoryFileEntry, '_setup_dnd', do_nothing)
-
+ setDoNothingHandlers(HistoryFileEntry, '_setup_dnd')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]