meld r1215 - trunk
- From: vincele svn gnome org
- To: svn-commits-list gnome org
- Subject: meld r1215 - trunk
- Date: Tue, 3 Mar 2009 00:35:44 +0000 (UTC)
Author: vincele
Date: Tue Mar 3 00:35:44 2009
New Revision: 1215
URL: http://svn.gnome.org/viewvc/meld?rev=1215&view=rev
Log:
Remove exception handling code by using rfind() instead of rindex()
Modified:
trunk/filediff.py
trunk/misc.py
trunk/prefs.py
Modified: trunk/filediff.py
==============================================================================
--- trunk/filediff.py (original)
+++ trunk/filediff.py Tue Mar 3 00:35:44 2009
@@ -844,9 +844,7 @@
texts[1] = [l+"\n" for l in texts[1]]
names = [self._get_pane_label(i) for i in range(2)]
prefix = os.path.commonprefix( names )
- try: prefixslash = prefix.rindex("/") + 1
- except ValueError: prefixslash = 0
- names = [n[prefixslash:] for n in names]
+ names = [n[prefix.rfind("/") + 1:] for n in names]
if sourceview_available:
dialog.textview.set_buffer( gsv.SourceBuffer() )
dialog.textview.modify_font(fontdesc)
Modified: trunk/misc.py
==============================================================================
--- trunk/misc.py (original)
+++ trunk/misc.py Tue Mar 3 00:35:44 2009
@@ -151,11 +151,8 @@
"""Remove redunant parts of a list of names (e.g. /tmp/foo{1,2} -> foo{1,2}
"""
prefix = os.path.commonprefix( names )
- try:
- prefixslash = prefix.rindex("/") + 1
- except ValueError:
- prefixslash = 0
-
+ prefixslash = prefix.rfind("/") + 1
+
names = map( lambda x: x[prefixslash:], names) # remove common prefix
paths = map( lambda x: x.split("/"), names) # split on /
Modified: trunk/prefs.py
==============================================================================
--- trunk/prefs.py (original)
+++ trunk/prefs.py Tue Mar 3 00:35:44 2009
@@ -114,7 +114,7 @@
pass
def _on_preference_changed(self, client, timestamp, entry, extra):
- attr = entry.key[ entry.key.rindex("/")+1 : ]
+ attr = entry.key[entry.key.rfind("/") + 1:]
try:
valuestruct = self._prefs[attr]
except KeyError: # unknown key, we don't care about it
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]