changeset 3070:ed1a433803c6

PEP8 fixes
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 22 Feb 2008 19:28:52 +0100
parents 15d744f727c9
children 103fd9035d50
files MoinMoin/_tests/test_packages.py MoinMoin/action/LikePages.py MoinMoin/action/PackagePages.py MoinMoin/action/newaccount.py MoinMoin/action/supplementation.py MoinMoin/action/userprofile.py MoinMoin/auth/ldap_login.py MoinMoin/parser/text_creole.py MoinMoin/parser/text_moin_wiki.py MoinMoin/request/__init__.py MoinMoin/script/export/package.py MoinMoin/script/xmlrpc/write.py MoinMoin/security/textcha.py MoinMoin/server/server_modpython.py MoinMoin/server/server_wsgi.py MoinMoin/theme/__init__.py MoinMoin/userform/admin.py
diffstat 17 files changed, 60 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_packages.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/_tests/test_packages.py	Fri Feb 22 19:28:52 2008 +0100
@@ -101,8 +101,8 @@
         package = PackagePages(self.request.rootpage.page_name, self.request)
         temp = tempfile.NamedTemporaryFile(suffix='.zip')
         package.collectpackage(self.request.rootpage.getPageList(
-                                include_underlay=False, 
-                                filter=lambda name: not wikiutil.isSystemPage(self.request, name)), 
+                                include_underlay=False,
+                                filter=lambda name: not wikiutil.isSystemPage(self.request, name)),
                                 temp)
         if package:
             py.test.skip("No user created pages in wiki!")
@@ -114,3 +114,4 @@
         package.collectpackage(['___//THIS PAGE SHOULD NOT EXIST\\___'], temp)
         assert not zipfile.is_zipfile(temp.name)
 coverage_modules = ['MoinMoin.packages']
+
--- a/MoinMoin/action/LikePages.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/action/LikePages.py	Fri Feb 22 19:28:52 2008 +0100
@@ -30,13 +30,13 @@
 
     # No matches
     if not matches:
-        request.theme.add_msg(_('No pages like "%s"!') % (pagename,), "error")
+        request.theme.add_msg(_('No pages like "%s"!') % (pagename, ), "error")
         Page(request, pagename).send_page()
         return
 
     # One match - display it
     if len(matches) == 1:
-        request.theme.add_msg(_('Exactly one page like "%s" found, redirecting to page.', formatted=False) % (pagename,), "info")
+        request.theme.add_msg(_('Exactly one page like "%s" found, redirecting to page.', formatted=False) % (pagename, ), "info")
         Page(request, matches.keys()[0]).send_page()
         return
 
--- a/MoinMoin/action/PackagePages.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/action/PackagePages.py	Fri Feb 22 19:28:52 2008 +0100
@@ -156,7 +156,7 @@
         """ Search MoinMoin for the string specified and return a list of
         matching pages, provided they are not system pages and not
         present in the underlay.
-        
+
         @param request: current request
         @param searchkey: string to search for
         @rtype: list
@@ -164,7 +164,7 @@
         """
 
         pagelist = searchPages(request, searchkey)
-        
+
         titles = []
         for title in pagelist.hits:
             if not wikiutil.isSystemPage(request, title.page_name) or not title.page.getPageStatus()[0]:
@@ -174,7 +174,7 @@
     def collectpackage(self, pagelist, fileobject, pkgname=""):
         """ Expects a list of pages as an argument, and fileobject to be an open
         file object, which a zipfile will get written to.
-        
+
         @param pagelist: pages to package
         @param fileobject: open file object to write to
         @param pkgname: optional file name, to prevent self packaging
--- a/MoinMoin/action/newaccount.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/action/newaccount.py	Fri Feb 22 19:28:52 2008 +0100
@@ -21,7 +21,7 @@
 
     if request.request_method != 'POST':
         return _("Use UserPreferences to change your settings or create an account.")
-           
+
     if not TextCha(request).check_answer_from_form():
         return _('TextCha: Wrong answer! Go back and try again...', formatted=False)
 
@@ -133,7 +133,7 @@
     row = html.TR()
     tbl.append(row)
     row.append(html.TD().append(html.STRONG().append(
-                                  html.Text(_('TextCha (required)', formatted=False))))) 
+                                  html.Text(_('TextCha (required)', formatted=False)))))
     td = html.TD()
     textcha = TextCha(request).render()
     if textcha:
@@ -179,3 +179,4 @@
 
         request.theme.send_footer(pagename)
         request.theme.send_closing_html()
+
--- a/MoinMoin/action/supplementation.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/action/supplementation.py	Fri Feb 22 19:28:52 2008 +0100
@@ -36,4 +36,4 @@
             request.theme.add_msg(errormsg, "error")
     else:
         request.theme.add_msg(errormsg, "error")
-        
\ No newline at end of file
+
--- a/MoinMoin/action/userprofile.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/action/userprofile.py	Fri Feb 22 19:28:52 2008 +0100
@@ -7,7 +7,7 @@
 """
 from MoinMoin.Page import Page
 from MoinMoin import user
- 
+
 def execute(pagename, request):
     """ set values in user profile """
     _ = request.getText
@@ -17,17 +17,17 @@
     if not request.user.isSuperUser():
         request.theme.add_msg(_("Only superuser is allowed to use this action."), "error")
     else:
-       user_name = form.get('name', [''])[0]
-       key = form.get('key', [''])[0]
-       val = form.get('val', [''])[0]
-       if key in cfg.user_checkbox_fields:
-           val = int(val)
-       uid = user.getUserId(request, user_name)
-       theuser = user.User(request, uid)
-       oldval = getattr(theuser, key)
-       setattr(theuser, key, val)
-       theuser.save()
-       request.theme.add_msg('%s.%s: %s -> %s' % (user_name, key, oldval, val), "info")
+        user_name = form.get('name', [''])[0]
+        key = form.get('key', [''])[0]
+        val = form.get('val', [''])[0]
+        if key in cfg.user_checkbox_fields:
+            val = int(val)
+        uid = user.getUserId(request, user_name)
+        theuser = user.User(request, uid)
+        oldval = getattr(theuser, key)
+        setattr(theuser, key, val)
+        theuser.save()
+        request.theme.add_msg('%s.%s: %s -> %s' % (user_name, key, oldval, val), "info")
 
     Page(request, pagename).send_page()
 
--- a/MoinMoin/auth/ldap_login.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/auth/ldap_login.py	Fri Feb 22 19:28:52 2008 +0100
@@ -86,7 +86,7 @@
                     except (ldap.SERVER_DOWN, ldap.CONNECT_ERROR), err:
                         if verbose: request.log("LDAP: Couldn't establish TLS to %r (err: %s)." % (server, str(err)))
                         raise
-  
+
                 # you can use %(username)s and %(password)s here to get the stuff entered in the form:
                 ldap_binddn = cfg.ldap_binddn % locals()
                 ldap_bindpw = cfg.ldap_bindpw % locals()
--- a/MoinMoin/parser/text_creole.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/parser/text_creole.py	Fri Feb 22 19:28:52 2008 +0100
@@ -413,7 +413,7 @@
                 buf.flush()
                 writ = buf.getvalue()
                 buf.close()
-                return ret+writ
+                return ret + writ
             except wikiutil.PluginMissingError:
                 pass
         return ''.join([
--- a/MoinMoin/parser/text_moin_wiki.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/parser/text_moin_wiki.py	Fri Feb 22 19:28:52 2008 +0100
@@ -1216,7 +1216,7 @@
                 self.parser_lines.append(word)
         else:
             self.in_pre = 'search_parser'
-        
+
         #logging.debug("_parser_repl: in_pre %r line %d" % (self.in_pre, self.lineno))
         return ''
     _parser_unique_repl = _parser_repl
--- a/MoinMoin/request/__init__.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/request/__init__.py	Fri Feb 22 19:28:52 2008 +0100
@@ -24,7 +24,7 @@
         The FIRST address in the <addrs> list might be the client's IP - if noone cheats
         and everyone supports x-f-f header.
 
-        See http://bob.pythonmac.org/archives/2005/09/23/apache-x-forwarded-for-caveat/                                                          
+        See http://bob.pythonmac.org/archives/2005/09/23/apache-x-forwarded-for-caveat/
 
         For debug loglevel, we log all <addrs>.
 
@@ -526,16 +526,16 @@
 
     def rewriteRemoteAddr(self, env):
         """ Rewrite remote_addr transparently
-        
+
         Get the proxy remote addr using 'X-Forwarded-For' header, added by
         Apache 2 and other proxy software.
-        
+
         TODO: Will not work for Apache 1 or others that don't add this header.
-        
+
         TODO: If we want to add an option to disable this feature it
         should be in the server script, because the config is not
         loaded at this point, and must be loaded after url is set.
-        
+
         @param env: dict like object containing cgi meta variables or http headers.
         """
         xff = (env.get(self.proxy_xff) or
--- a/MoinMoin/script/export/package.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/script/export/package.py	Fri Feb 22 19:28:52 2008 +0100
@@ -35,7 +35,7 @@
             "-s", "--search", dest="search",
             help="Search string to match."
         )
-        
+
         self.parser.add_option(
             "-u", "--user", dest="package_user",
             help="User as whom the package operation will be performed as. "
@@ -43,12 +43,12 @@
 
     def mainloop(self):
         """ moin-package's main code. """
-        
+
         # Initalize request
         self.init_request()
         request = self.request
         _ = self.request.getText
-        
+
         # Check our command line args
         if self.options.pages and self.options.search:
             script.fatal(_("Options --pages and --search are mutually exclusive!"))
@@ -60,14 +60,14 @@
         # Sanity checks
         if os.path.exists(self.options.output):
             script.fatal(_("Output file already exists! Cowardly refusing to continue!"))
-        
+
         # Check for user
         if self.options.package_user:
             request.user = user.User(request, name=self.options.package_user)
-        
+
         # Import PackagePages here, as we now have an initalized request.
         from MoinMoin.action.PackagePages import PackagePages
-        
+
         # Perform actual packaging.
         package = PackagePages(request.rootpage.page_name, request)
         packageoutput = open(self.options.output, "wb")
@@ -78,8 +78,9 @@
                 packagedata = package.collectpackage(self.options.pages.split(","), packageoutput)
         else:
                 packagedata = package.collectpackage(request.rootpage.getPageList(
-                                include_underlay=False, 
-                                filter=lambda name: not wikiutil.isSystemPage(request, name)), 
+                                include_underlay=False,
+                                filter=lambda name: not wikiutil.isSystemPage(request, name)),
                                 packageoutput)
         if packagedata:
             script.fatal(packagedata)
+
--- a/MoinMoin/script/xmlrpc/write.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/script/xmlrpc/write.py	Fri Feb 22 19:28:52 2008 +0100
@@ -59,9 +59,10 @@
             # but you should definitely access all the results
             # once so that faults are checked and raised
             assert results[0] == 'SUCCESS'
-            assert results[1] == True
+            assert results[1] is True
 
         finally:
             # be nice to the server and clean up the token
             # regardless of what happened
             assert s.deleteAuthToken(token) == 'SUCCESS'
+
--- a/MoinMoin/security/textcha.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/security/textcha.py	Fri Feb 22 19:28:52 2008 +0100
@@ -1,7 +1,7 @@
 # -*- coding: iso-8859-1 -*-
 """
     MoinMoin - Text CAPTCHAs
-    
+
     This is just asking some (admin configured) questions and
     checking if the answer is as expected. It is up to the wiki
     admin to setup questions that a bot can not easily answer, but
@@ -73,7 +73,7 @@
 
     def _init_qa(self, question=None):
         """ Initialize the question / answer.
-        
+
          @param question: If given, the given question will be used.
                           If None, a new question will be generated.
         """
@@ -107,7 +107,7 @@
                 },
                 'de': {}, # having no questions for 'de' means disabling textchas for 'de'
                 # ...
-            }             
+            }
         """
         return not not self.textchas # we don't want to return the dict
 
@@ -142,8 +142,8 @@
     def render(self, form=None):
         """ Checks if textchas are enabled and returns HTML for one,
             or an empty string if they are not enabled.
-            
-            @return: unicode result html         
+
+            @return: unicode result html
         """
         if self.is_enabled():
             question, given_answer = self._extract_form_values(form)
@@ -168,3 +168,4 @@
             return self.check_answer(given_answer)
         else:
             return True
+
--- a/MoinMoin/server/server_modpython.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/server/server_modpython.py	Fri Feb 22 19:28:52 2008 +0100
@@ -9,12 +9,12 @@
     Minimal usage:
 
         from MoinMoin.server.server_modpython import CgiConfig, run
-        
+
         class Config(CgiConfig):
             pass
 
         run(Config)
-        
+
     See more options in CgiConfig class.
 
     @copyright: 2006 MoinMoin:ThomasWaldmann
@@ -39,7 +39,7 @@
 
     logPath = None
     properties = {}
-    
+
     # Set up log handler to log to apache log!
 
 def modpythonHandler(request, ConfigClass=ModpythonConfig):
--- a/MoinMoin/server/server_wsgi.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/server/server_wsgi.py	Fri Feb 22 19:28:52 2008 +0100
@@ -5,7 +5,7 @@
 
     import logging
     from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp
-    
+
     class Config(WsgiConfig):
         logPath = 'moin.log' # define your log file here
         #loglevel_file = logging.INFO # if you do not like the default
@@ -24,7 +24,7 @@
 class WsgiConfig(Config):
     """ WSGI default config """
     loglevel_stderr = None # we do not want to write to stderr!
-         
+
 
 def moinmoinApp(environ, start_response):
     request = request_wsgi.Request(environ)
--- a/MoinMoin/theme/__init__.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/theme/__init__.py	Fri Feb 22 19:28:52 2008 +0100
@@ -1119,7 +1119,7 @@
 
            If the discussion page doesn't exist and the user
            has no right to create it, show a disabled link.
-	"""
+        """
         _ = self.request.getText
         suppl_name = self.request.cfg.supplementation_page_name
         suppl_name_full = "%s/%s" % (page.page_name, suppl_name)
@@ -1458,12 +1458,12 @@
     def add_msg(self, msg, msg_class="dialog"):
         """ Adds a message to a list which will be used to generate status
         information.
-        
+
         @param msg: additional message
         @param msg_class: html class for the div of the additional message.
         """
         if self._send_title_called:
-            raise Exception("You cannot call add_msg() after send_title()") 
+            raise Exception("You cannot call add_msg() after send_title()")
         self._status.append((msg, msg_class))
 
     # stuff from wikiutil.py
@@ -1493,7 +1493,7 @@
             pagename = keywords.get('pagename', '')
             page = Page(request, pagename)
         if keywords.get('msg', ''):
-            raise DeprecationWarning ("Using send_page(msg=) is deprecated! Use theme.add_msg() instead!")
+            raise DeprecationWarning("Using send_page(msg=) is deprecated! Use theme.add_msg() instead!")
         scriptname = request.getScriptname()
         pagename_quoted = wikiutil.quoteWikinameURL(pagename)
 
--- a/MoinMoin/userform/admin.py	Fri Feb 22 18:31:22 2008 +0100
+++ b/MoinMoin/userform/admin.py	Fri Feb 22 19:28:52 2008 +0100
@@ -48,7 +48,7 @@
         if account.disabled:
             enable_disable_link = request.page.link_to(
                                     request, text=_('Enable user'),
-                                    querystr={"action":"userprofile",
+                                    querystr={"action": "userprofile",
                                               "name": account.name,
                                               "key": "disabled",
                                               "val": "0",
@@ -58,7 +58,7 @@
         else:
             enable_disable_link = request.page.link_to(
                                     request, text=_('Disable user'),
-                                    querystr={"action":"userprofile",
+                                    querystr={"action": "userprofile",
                                               "name": account.name,
                                               "key": "disabled",
                                               "val": "1",