changeset 275:8236b972ea7d

better use .startswith/.endswith instead of [0]/[-1] imported from: moin--main--1.5--patch-279
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 02 Dec 2005 23:11:44 +0000
parents 85458b71e188
children 9b21b7907167
files MoinMoin/converter/text_html_text_x_moin.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_x_moin.py	Fri Dec 02 22:57:30 2005 +0000
+++ b/MoinMoin/converter/text_html_text_x_moin.py	Fri Dec 02 23:11:44 2005 +0000
@@ -472,7 +472,7 @@
             if text[i] is self.white_space:
                 if i == 0 or i == len(text)-1:
                     del text[i]
-                elif text[i-1][-1] in (" ", "\n",):
+                elif text[i-1].endswith(" ") or text[i-1].endswith("\n"):
                     # last char of previous element is whitespace
                     del text[i]
                 elif (text[i+1] is self.white_space or
@@ -480,7 +480,7 @@
                       text[i+1] is self.new_line):
                       # or new_line
                     del text[i]
-                elif text[i+1][0] in (" ", "\n",):
+                elif text[i+1].startswith(" ") or text[i+1].startswith("\n"):
                     # first char of next element is whitespace
                     del text[i]
                 else:
@@ -492,8 +492,8 @@
                 elif i == len(text) - 1:
                     text[i] = "\n"
                     i += 1
-                elif text[i-1][-1] == "\n" or (
-                      isinstance(text[i+1], str) and text[i+1][0] == "\n"):
+                elif text[i-1].endswith("\n") or (
+                      isinstance(text[i+1], str) and text[i+1].startswith("\n")):
                     del text[i]
                 else:
                     text[i] = "\n"