changeset 1183:bc84eae93f8c

replace usage of find by 'in' operator
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 14 Aug 2006 01:24:01 +0200
parents 5de0dc972701
children b1deb9496f41
files MoinMoin/action/newpage.py MoinMoin/formatter/__init__.py MoinMoin/formatter/text_html.py MoinMoin/macro/NewPage.py MoinMoin/macro/RecentChanges.py MoinMoin/macro/__init__.py MoinMoin/parser/text_rst.py MoinMoin/request/__init__.py
diffstat 8 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/newpage.py	Mon Aug 14 00:54:29 2006 +0200
+++ b/MoinMoin/action/newpage.py	Mon Aug 14 01:24:01 2006 +0200
@@ -29,7 +29,7 @@
         @return: error message
         """
         _ = self.request.getText
-        need_replace = self.nametemplate.find('%s') != -1
+        need_replace = '%s' in self.nametemplate
         if not self.pagename and need_replace:
             return _("Cannot create a new page without a page name."
                      "  Please specify a page name.")
@@ -38,7 +38,7 @@
         # template variable
             repl = 'A@'
             i = 0
-            while self.nametemplate.find(repl) != -1:
+            while repl in self.nametemplate:
                 repl += ['#', '&', '$', 'x', 'X', ':', '@'][i]
                 i += 1
                 i = i % 7
--- a/MoinMoin/formatter/__init__.py	Mon Aug 14 00:54:29 2006 +0200
+++ b/MoinMoin/formatter/__init__.py	Mon Aug 14 01:24:01 2006 +0200
@@ -97,7 +97,7 @@
         """
         wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, '%s:"%s"' % (interwiki, pagename))
         if wikitag == 'Self' or wikitag == self.request.cfg.interwikiname:
-            if wikitail.find('#') > -1:
+            if '#' in wikitail:
                 wikitail, kw['anchor'] = wikitail.split('#', 1)
                 wikitail = wikiutil.url_unquote(wikitail)
             return self.pagelink(on, wikitail, **kw)
--- a/MoinMoin/formatter/text_html.py	Mon Aug 14 00:54:29 2006 +0200
+++ b/MoinMoin/formatter/text_html.py	Mon Aug 14 01:24:01 2006 +0200
@@ -506,7 +506,7 @@
         wikiurl = wikiutil.mapURL(self.request, wikiurl)
         if wikitag == 'Self': # for own wiki, do simple links
             if on:
-                if wikitail.find('#') > -1:
+                if '#' in wikitail:
                     wikitail, kw['anchor'] = wikitail.split('#', 1)
                 wikitail = wikiutil.url_unquote(wikitail)
                 try: # XXX this is the only place where we access self.page - do we need it? Crashes silently on actions!
--- a/MoinMoin/macro/NewPage.py	Mon Aug 14 00:54:29 2006 +0200
+++ b/MoinMoin/macro/NewPage.py	Mon Aug 14 01:24:01 2006 +0200
@@ -79,7 +79,7 @@
         if parent == '@ME' and self.request.user.valid:
             parent = self.request.user.name
 
-        requires_input = nametemplate.find('%s') != -1
+        requires_input = '%s' in nametemplate
 
         if label:
             # Try to get a translation, this will probably not work in
--- a/MoinMoin/macro/RecentChanges.py	Mon Aug 14 00:54:29 2006 +0200
+++ b/MoinMoin/macro/RecentChanges.py	Mon Aug 14 01:24:01 2006 +0200
@@ -38,7 +38,7 @@
         elif line.action == 'ATTDRW':
             comment = _("Drawing '%(filename)s' saved.") % {
                 'filename': filename}
-    elif line.action.find('/REVERT') != -1:
+    elif '/REVERT' in line.action:
         rev = int(line.extra)
         comment = _("Revert to revision %(rev)d.") % {'rev': rev}
 
--- a/MoinMoin/macro/__init__.py	Mon Aug 14 00:54:29 2006 +0200
+++ b/MoinMoin/macro/__init__.py	Mon Aug 14 01:24:01 2006 +0200
@@ -342,7 +342,7 @@
         for tag, url in list:
             buf.write('<dt><tt><a href="%s">%s</a></tt></dt>' % (
                 wikiutil.join_wiki(url, 'RecentChanges'), tag))
-            if url.find('$PAGE') == -1:
+            if '$PAGE' not in url:
                 buf.write('<dd><tt><a href="%s">%s</a></tt></dd>' % (url, url))
             else:
                 buf.write('<dd><tt>%s</tt></dd>' % url)
@@ -462,7 +462,7 @@
         from MoinMoin.mail.sendmail import decodeSpamSafeEmail
 
         args = args or ''
-        if args.find(',') == -1:
+        if ',' not in args:
             email = args
             text = ''
         else:
--- a/MoinMoin/parser/text_rst.py	Mon Aug 14 00:54:29 2006 +0200
+++ b/MoinMoin/parser/text_rst.py	Mon Aug 14 01:24:01 2006 +0200
@@ -382,7 +382,7 @@
                 # Default case - make a link to a wiki page.
                 pagename = refuri
                 anchor = ''
-                if refuri.find('#') != -1:
+                if '#' in refuri:
                     pagename, anchor = refuri.split('#', 1)
                     anchor = '#' + anchor
                 page = Page(self.request, pagename)
--- a/MoinMoin/request/__init__.py	Mon Aug 14 00:54:29 2006 +0200
+++ b/MoinMoin/request/__init__.py	Mon Aug 14 01:24:01 2006 +0200
@@ -327,7 +327,7 @@
             accept_charset = accept_charset.lower()
             # Add iso-8859-1 if needed
             if (not '*' in accept_charset and
-                accept_charset.find('iso-8859-1') < 0):
+                'iso-8859-1' not in accept_charset):
                 accept_charset += ',iso-8859-1'
 
             # Make a list, sorted by quality value, using Schwartzian Transform
@@ -433,7 +433,7 @@
         """
         # Fix the script_name when using Apache on Windows.
         server_software = env.get('SERVER_SOFTWARE', '')
-        if os.name == 'nt' and server_software.find('Apache/') != -1:
+        if os.name == 'nt' and 'Apache/' in server_software:
             # Removes elements ending in '.' from the path.
             self.script_name = '/'.join([x for x in self.script_name.split('/')
                                          if not x.endswith('.')])