changeset 3992:513613f25bbf

fix source code with PEP8
author Byeongweon [tasyblue@gmail.com]
date Sat, 02 Aug 2008 18:00:41 +0900
parents 42c243588d64
children e0301e5bf019
files MoinMoin/converter/text_html_text_moin_wiki.py MoinMoin/formatter/text_gedit.py
diffstat 2 files changed, 67 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Fri Aug 01 16:41:25 2008 +0900
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Aug 02 18:00:41 2008 +0900
@@ -815,44 +815,42 @@
         self.text.append(command)
 
     def process_span(self, node):
-        # process span tag for firefox3
-        # see this : http://dev.fckeditor.net/ticket/2210
-
-        node_style = node.getAttribute("style")        
-      
-        is_strike = node.getAttribute("class") == "strike"
-        is_strike = is_strike or "line-through" in node_style
-        is_strong = "bold" in node_style
-        is_italic = "italic" in node_style
-        is_underline = "underline" in node_style
-        is_comment = node.getAttribute("class") == "comment"
-
-        # start tag        
-        if is_comment:
+        # process span tag for firefox3
+        node_style = node.getAttribute("style")
+
+        is_strike = node.getAttribute("class") == "strike"
+        is_strike = is_strike or "line-through" in node_style
+        is_strong = "bold" in node_style
+        is_italic = "italic" in node_style
+        is_underline = "underline" in node_style
+        is_comment = node.getAttribute("class") == "comment"
+
+        # start tag
+        if is_comment:
             self.text.append("/* ")
         if is_strike:
-            self.text.append("--(")
-        if is_strong:
-            self.text.append("'''")
-        if is_italic:
+            self.text.append("--(")
+        if is_strong:
+            self.text.append("'''")
+        if is_italic:
             self.text.append("''")
-        if is_underline:
-            self.text.append("__")
-
-        # body        
+        if is_underline:
+            self.text.append("__")
+
+        # body
         for i in node.childNodes:
             self.process_inline(i)
-
-        # end tag
-        if is_underline:
+
+        # end tag
+        if is_underline:
             self.text.append("__")
-        if is_italic:
+        if is_italic:
             self.text.append("''")
-        if is_strong:
-            self.text.append("'''")
+        if is_strong:
+            self.text.append("'''")
         if is_strike:
-            self.text.append(")--")
-        if is_comment:
+            self.text.append(")--")
+        if is_comment:
             self.text.append(" */")
 
     def process_div(self, node):
@@ -878,16 +876,16 @@
             length = 4
         self.text.extend([self.new_line, "-" * length, self.new_line])
 
-    def process_p(self, node):
-        # process indent
-        node_style = node.getAttribute("style")
-        match = re.match(r"margin-left:\s*(\d+)px", node_style)
-        if match:
-            left_margin = int(match.group(1))
-            indent_depth = int(left_margin / 40)
-            if indent_depth > 0:
-                self.text.append(' . ')
-            
+    def process_p(self, node):
+        # process indent
+        node_style = node.getAttribute("style")
+        match = re.match(r"margin-left:\s*(\d+)px", node_style)
+        if match:
+            left_margin = int(match.group(1))
+            indent_depth = int(left_margin / 40)
+            if indent_depth > 0:
+                self.text.append(' . ')
+
         self.process_paragraph_item(node)
         self.text.append("\n\n") # do not use self.new_line here!
 
@@ -910,39 +908,40 @@
         if class_ == "comment": # we currently use this for stuff like ## or #acl
             for i in node.childNodes:
                 if i.nodeType == Node.TEXT_NODE:
-                    self.text.append(i.data.replace('\n', '')) # remove useless new line
-                    #print "'%s'" % i.data.replace('\n', '')
+                    self.text.append(i.data.replace('\n', ''))
                 elif i.localName == 'br':
                     self.text.append(self.new_line)
                 else:
                     pass
-                    #print i.localName
-        else:
-            content_buffer = []
+        else:
+            content_buffer = []
             longest_inner_formater = ''
-
+
             for i in node.childNodes:
-                if i.nodeType == Node.TEXT_NODE:
-                    # get longest pre tag({{{) from content
-                    delimiters = re.compile("(?u){+").findall(i.data)
-                    if delimiters:
-                        longest_inner_formater = max([longest_inner_formater, max(delimiters)])
+                if i.nodeType == Node.TEXT_NODE:
+                    # get longest pre tag({{{) from content
+                    delimiters = re.compile("(?u){+").findall(i.data)
+                    if delimiters:
+                        longest_inner_formater = max([longest_inner_formater,\
+                                                      max(delimiters)])
                     content_buffer.append(i.data)
                     #print "'%s'" % i.data
-                elif i.localName == 'br':
+                elif i.localName == 'br':
                     content_buffer.append(self.new_line_dont_remove)
                 else:
                     pass
-                    #print i.localName
-
-            if (len(longest_inner_formater) >= 3):
-                self.text.extend(["{" * (len(longest_inner_formater) + 1), self.new_line])
-                self.text.extend(content_buffer)
-                self.text.extend(["}" * (len(longest_inner_formater) + 1), self.new_line])
-            else:                
-                self.text.extend(["{{{", self.new_line])
-                self.text.extend(content_buffer)
-                self.text.extend(["}}}", self.new_line])
+                    #print i.localName
+
+            if (len(longest_inner_formater) >= 3):
+                self.text.extend(["{" * (len(longest_inner_formater) + 1), \
+                                  self.new_line])
+                self.text.extend(content_buffer)
+                self.text.extend(["}" * (len(longest_inner_formater) + 1), \
+                                      self.new_line])
+            else:
+                self.text.extend(["{{{", self.new_line])
+                self.text.extend(content_buffer)
+                self.text.extend(["}}}", self.new_line])
 
     _alignment = {"left": "(",
                   "center": ":",
@@ -1348,7 +1347,7 @@
 def parse(request, text):
     text = u'<?xml version="1.0"?>%s%s' % (dtd, text)
     text = text.encode(config.charset)
-    try:
+    try:
         return xml.dom.minidom.parseString(text)
     except xml.parsers.expat.ExpatError, msg:
         # this sometimes crashes when it should not, so save the stuff to analyze it:
--- a/MoinMoin/formatter/text_gedit.py	Fri Aug 01 16:41:25 2008 +0900
+++ b/MoinMoin/formatter/text_gedit.py	Sat Aug 02 18:00:41 2008 +0900
@@ -234,9 +234,9 @@
     def line_anchorlink(self, on, lineno=0):
         return '' # not needed for gui editor feeding
 
-    def span(self, on, **kw):
-        previous_state = self.request.user.show_comments
-        self.request.user.show_comments = True
-        ret = text_html.Formatter.span(self, on, **kw)
-        self.request.user.show_comments = previous_state
+    def span(self, on, **kw):
+        previous_state = self.request.user.show_comments
+        self.request.user.show_comments = True
+        ret = text_html.Formatter.span(self, on, **kw)
+        self.request.user.show_comments = previous_state
         return ret