changeset 889:ad62767ffd0c

pep8 style changes
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 06 Jul 2006 17:16:26 +0200
parents d3066011d048
children de485daead4a
files MoinMoin/action/AttachFile.py MoinMoin/action/DeletePage.py MoinMoin/action/Despam.py MoinMoin/i18n/__init__.py
diffstat 4 files changed, 51 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Thu Jul 06 16:22:04 2006 +0200
+++ b/MoinMoin/action/AttachFile.py	Thu Jul 06 17:16:26 2006 +0200
@@ -121,7 +121,7 @@
     if not files: return ''
 
     attach_count = _('[%d attachments]') % len(files)
-    attach_icon = request.theme.make_icon('attach', vars={ 'attach_count': attach_count })
+    attach_icon = request.theme.make_icon('attach', vars={'attach_count': attach_count})
     attach_link = wikiutil.link_tag(request,
         "%s?action=AttachFile" % wikiutil.quoteWikinameURL(pagename),
         attach_icon,
@@ -192,7 +192,7 @@
         os.chmod(fpath, 0666 & config.umask)
 
         _addLogEntry(request, 'ATTNEW', pagename, target)
-        
+
         return target
 
 
@@ -268,7 +268,7 @@
         label_install = _("install")
 
         for file in files:
-            fsize = float(os.stat(os.path.join(attach_dir,file).encode(config.charset))[6]) # in byte
+            fsize = float(os.stat(os.path.join(attach_dir, file).encode(config.charset))[6]) # in byte
             fsize = "%.1f" % (fsize / 1024)
             baseurl = request.getScriptname()
             action = action_name
@@ -301,7 +301,7 @@
             if (packages.ZipPackage(request, os.path.join(attach_dir, file).encode(config.charset)).isPackage() and
                 request.user.isSuperUser()):
                 viewlink += ' | <a href="%(baseurl)s/%(urlpagename)s?action=%(action)s&amp;do=install&amp;target=%(urlfile)s">%(label_install)s</a>' % parmdict
-            elif (zipfile.is_zipfile(os.path.join(attach_dir,file).encode(config.charset)) and
+            elif (zipfile.is_zipfile(os.path.join(attach_dir, file).encode(config.charset)) and
                 request.user.may.read(pagename) and request.user.may.delete(pagename)
                 and request.user.may.write(pagename)):
                 viewlink += ' | <a href="%(baseurl)s/%(urlpagename)s?action=%(action)s&amp;do=unzip&amp;target=%(urlfile)s">%(label_unzip)s</a>' % parmdict
@@ -581,7 +581,7 @@
         bsindex = target.rfind('\\')
         if bsindex >= 0:
             target = target[bsindex+1:]
-    
+
     # add the attachment
     try:
         add_attachment(request, pagename, target, filecontent)
@@ -613,10 +613,10 @@
 
     if ext == '.draw':
         _addLogEntry(request, 'ATTDRW', pagename, basename + ext)
-        filecontent = filecontent.replace("\r","")
+        filecontent = filecontent.replace("\r", "")
 
     savepath = os.path.join(getAttachDir(request, pagename), basename + ext)
-    if ext == '.map' and filecontent.strip()=='':
+    if ext == '.map' and not filecontent.strip():
         # delete map file if it is empty
         os.unlink(savepath)
     else:
@@ -675,9 +675,9 @@
 
     if package.isPackage():
         if package.installPackage():
-            msg=_("Attachment '%(filename)s' installed.") % {'filename': wikiutil.escape(target)}
+            msg = _("Attachment '%(filename)s' installed.") % {'filename': wikiutil.escape(target)}
         else:
-            msg=_("Installation of '%(filename)s' failed.") % {'filename': wikiutil.escape(target)}
+            msg = _("Installation of '%(filename)s' failed.") % {'filename': wikiutil.escape(target)}
         if package.msg != "":
             msg += "<br><pre>" + wikiutil.escape(package.msg) + "</pre>"
     else:
@@ -710,7 +710,7 @@
 
         available_attachments_file_space = attachments_file_space - fsize
         available_attachments_file_count = attachments_file_count - fcount
-        
+
         if zipfile.is_zipfile(fpath):
             zf = zipfile.ZipFile(fpath)
             sum_size_over_all_valid_files = 0.0
@@ -727,19 +727,19 @@
                     count_valid_files += 1
 
             if sum_size_over_all_valid_files > available_attachments_file_space:
-                msg=_("Attachment '%(filename)s' could not be unzipped because"
-                      " the resulting files would be too large (%(space)d kB"
-                      " missing).") % {
-                        'filename': filename,
-                        'space': (sum_size_over_all_valid_files -
-                              available_attachments_file_space) / 1000 }
+                msg = _("Attachment '%(filename)s' could not be unzipped because"
+                        " the resulting files would be too large (%(space)d kB"
+                        " missing).") % {
+                            'filename': filename,
+                            'space': (sum_size_over_all_valid_files -
+                                available_attachments_file_space) / 1000 }
             elif count_valid_files > available_attachments_file_count:
-                msg=_("Attachment '%(filename)s' could not be unzipped because"
-                      " the resulting files would be too many (%(count)d "
-                      "missing).") % {
-                        'filename': filename,
-                        'count': (count_valid_files -
-                                  available_attachments_file_count) }
+                msg = _("Attachment '%(filename)s' could not be unzipped because"
+                        " the resulting files would be too many (%(count)d "
+                        "missing).") % {
+                            'filename': filename,
+                            'count': (count_valid_files -
+                                available_attachments_file_count) }
             else:
                 valid_name = False
                 for (origname, finalname) in namelist.iteritems():
@@ -760,11 +760,11 @@
                                     _addLogEntry(request, 'ATTNEW', pagename, finalname)
 
                 if valid_name:
-                    msg=_("Attachment '%(filename)s' unzipped.") % {'filename': filename}
+                    msg = _("Attachment '%(filename)s' unzipped.") % {'filename': filename}
                 else:
-                    msg=_("Attachment '%(filename)s' not unzipped because the "
-                          "files are too big, .zip files only, exist already or "
-                          "reside in folders.") % {'filename': filename}
+                    msg = _("Attachment '%(filename)s' not unzipped because the "
+                            "files are too big, .zip files only, exist already or "
+                            "reside in folders.") % {'filename': filename}
         else:
             msg = _('The file %(target)s is not a .zip file.' % target)
 
@@ -798,7 +798,7 @@
 
     package = packages.ZipPackage(request, fpath)
     if package.isPackage():
-        request.write("<pre><b>%s</b>\n%s</pre>" % (_("Package script:"),wikiutil.escape(package.getScript())))
+        request.write("<pre><b>%s</b>\n%s</pre>" % (_("Package script:"), wikiutil.escape(package.getScript())))
         return
 
     import zipfile
@@ -854,7 +854,7 @@
     data.columns = [
         Column('page', label=('Page')),
         Column('file', label=('Filename')),
-        Column('size',  label=_('Size'), align='right'),
+        Column('size', label=_('Size'), align='right'),
         #Column('action', label=_('Action')),
     ]
 
--- a/MoinMoin/action/DeletePage.py	Thu Jul 06 16:22:04 2006 +0200
+++ b/MoinMoin/action/DeletePage.py	Thu Jul 06 17:16:26 2006 +0200
@@ -27,20 +27,20 @@
     def is_allowed(self):
         may = self.request.user.may
         return may.write(self.pagename) and may.delete(self.pagename)
-    
+
     def check_condition(self):
         _ = self._
         if not self.page.exists():
             return _('This page is already deleted or was never created!')
         else:
             return None
-        
+
     def do_action(self):
         """ Delete pagename """
         form = self.form
         comment = form.get('comment', [u''])[0]
         comment = wikiutil.clean_comment(comment)
-        
+
         # Create a page editor that does not do editor backups, because
         # delete generates a "deleted" version of the page.
         self.page = PageEditor(self.request, self.pagename, do_editor_backup=0)
--- a/MoinMoin/action/Despam.py	Thu Jul 06 16:22:04 2006 +0200
+++ b/MoinMoin/action/Despam.py	Thu Jul 06 17:16:26 2006 +0200
@@ -17,8 +17,8 @@
 from MoinMoin.macro import RecentChanges
 
 def show_editors(request, pagename, timestamp):
-    _ =  request.getText
-    
+    _ = request.getText
+
     timestamp = int(timestamp * 1000000)
     log = editlog.EditLog(request)
     editors = {}
@@ -26,15 +26,15 @@
     for line in log.reverse():
         if line.ed_time_usecs < timestamp:
             break
-        
+
         if not request.user.may.read(line.pagename):
             continue
-        
+
         editor = line.getEditor(request)
         if not line.pagename in pages:
             pages[line.pagename] = 1
             editors[editor] = editors.get(editor, 0) + 1
-            
+
     editors = [(nr, editor) for editor, nr in editors.iteritems()]
     editors.sort()
 
@@ -46,7 +46,7 @@
                        Column('link', label='', align='left')]
     for nr, editor in editors:
         dataset.addRow((editor, unicode(nr), pg.link_to(request, text=_("Select Author"), querystr="action=Despam&editor=%s" % wikiutil.url_quote_plus(editor))))
-    
+
     table = DataBrowserWidget(request)
     table.setData(dataset)
     table.render()
@@ -55,8 +55,8 @@
     pass
 
 def show_pages(request, pagename, editor, timestamp):
-    _ =  request.getText
-    
+    _ = request.getText
+
     timestamp = int(timestamp * 1000000)
     log = editlog.EditLog(request)
     lines = []
@@ -70,7 +70,7 @@
     for line in log.reverse():
         if line.ed_time_usecs < timestamp:
             break
-        
+
         if not request.user.may.read(line.pagename):
             continue
 
@@ -125,9 +125,9 @@
         except pg.SaveError, msg:
             savemsg = unicode(msg)
     return savemsg
-    
+
 def revert_pages(request, editor, timestamp):
-    _ =  request.getText
+    _ = request.getText
 
     editor = wikiutil.url_unquote(editor, want_unicode=False)
     timestamp = int(timestamp * 1000000)
@@ -162,7 +162,7 @@
     if actname in request.cfg.actions_excluded or \
        not request.user.isSuperUser():
         return Page.Page(request, pagename).send_page(request,
-            msg = _('You are not allowed to use this action.'))
+            msg=_('You are not allowed to use this action.'))
 
     editor = request.form.get('editor', [None])[0]
     timestamp = time.time() - 24 * 3600
@@ -170,10 +170,10 @@
     ok = request.form.get('ok', [0])[0]
 
     request.http_headers()
-    request.theme.send_title("Despam", pagename=pagename)    
+    request.theme.send_title("Despam", pagename=pagename)
     # Start content (important for RTL support)
     request.write(request.formatter.startContent("content"))
-    
+
     if ok:
         revert_pages(request, editor, timestamp)
     elif editor:
--- a/MoinMoin/i18n/__init__.py	Thu Jul 06 16:22:04 2006 +0200
+++ b/MoinMoin/i18n/__init__.py	Thu Jul 06 17:16:26 2006 +0200
@@ -97,7 +97,7 @@
     def __init__(self, language, domain='MoinMoin'):
         self.language = language
         self.domain = domain
-        
+
     def load_mo(self, filename):
         """ load the mo file, setup some attributes from metadata """
         # binary files have to be opened in the binary file mode!
@@ -108,7 +108,7 @@
         self.direction = info['x-direction']
         assert self.direction in ('ltr', 'rtl', )
         self.maintainer = info['last-translator']
-    
+
     def formatMarkup(self, request, text, currentStack=[]):
         """
         Formats the text passed according to wiki markup.
@@ -140,7 +140,7 @@
         formatter.setPage(p)
         parser.format(formatter)
         text = out.getvalue()
-        if reqformatter == None:
+        if reqformatter is None:
             del request.formatter
         else:
             request.formatter = reqformatter
@@ -186,10 +186,10 @@
             if debug:
                 request.log("i18n: dumping lang %s" % lang)
             cache.update(pickle.dumps((uc_texts, uc_unformatted), PICKLE_PROTOCOL))
-        
+
         self.formatted = uc_texts
         self.raw = uc_unformatted
-        
+
 
 def getDirection(lang):
     """ Return the text direction for a language, either 'ltr' or 'rtl'. """
@@ -273,7 +273,7 @@
                 if request.http_accept_language:
                     request.setHttpHeader('Vary: Accept-Language')
                 return lang
-    
+
     # Or return the wiki default language...
     if request.cfg.language_default in available:
         lang = request.cfg.language_default