Commits

clach04  committed b05f60c

pep8 changes, mostly newline and comment clean up.

  • Participants
  • Parent commits a288ffe

Comments (0)

Files changed (1)

File python/pottymouth.py

 # bold => ( atomic | italic ) +
 # italic => ( atomic | italic ) +
 
-import re, sys
+import re
+import sys
 
 __version__ = '2.1.3'
 short_line_length = 50
-encoding = 'utf8' # Default output encoding
+encoding = 'utf8'  # Default output encoding
 
 
 class TokenMatcher(object):
 
 list_tokens = ('HASH', 'NUMBERED', 'DASH', 'ITEMSTAR', 'BULLET') # for convenience only
 
+
 # The "Replacers" are context sensitive replacements, therefore they
 # must be applied in-line to the string as a whole before tokenizing.
 # Another option would be to keep track of previous context when
     ]
 
 
-
 class Token(unicode):
 
     def __new__(cls, name, content=''):
         return self.encode(encoding, 'xmlcharrefreplace')
 
 
-
 # escape() is made available to calling code in case it needs to
 # escape the content of PottyMouth Nodes before converting it to
 # another tree object that does not automatically escape these
     return out
 
 
-
 class Node(list):
 
     def __init__(self, name, *contents, **kw):
         self.extend(contents)
         self._attributes = kw.get('attributes', {})
 
-
     def node_children(self):
         for n in self:
             if isinstance(n, Node):
                 return True
         return False
 
-
     def _inner_content(self, strip=True):
         content = ''
         for c in self:
             content = content.strip()
         return content
 
-
     def __str__(self):
         if self.name in ('br','img'): # Also <hr>
             # <br></br> causes double-newlines, so we do this
         else:
             return '<%s%s>%s</%s>' % (self.name, self._attribute_string(), self._inner_content(), self.name)
 
-
     def _attribute_string(self):
         content = ''
         if self._attributes:
         return content
 
 
-
 class URLNode(Node):
 
     def __init__(self, content, internal=False):
         Node.__init__(self, 'a', content, attributes=attributes)
 
 
-
 class LinkNode(URLNode):
 
     pass
 
 
-
 class EmailNode(URLNode):
 
     def __init__(self, content, internal=False):
         Node.__init__(self, 'a', content, attributes=attributes)
 
 
-
 class ImageNode(Node):
 
     def __init__(self, content):
         Node.__init__(self, 'img', '', attributes={'src':content})
 
 
-
 class YouTubeNode(Node):
 
     def __init__(self, content):
                                      'width':'425', 'height':'350',}))
 
 
-
 def debug(*a):
     print ' '.join(map(repr, a))
 
 
-
 class PottyMouth(object):
 
     def __init__(self, url_check_domains=(), url_white_lists=(),
 
             self.token_list.append(t)
 
-
     def debug(self, *s):
         return
         print ' '.join(map(str, s))
 
-
     def pre_replace(self, string):
         for r in self.replacer_list:
             string = r.sub(string)
         return string
 
-
     def tokenize(self, string):
         p = 0
         found_tokens = []
 
         return found_tokens
 
-
     def handle_url(self, t):
         if not protocol_pattern.match(unicode(t)):
             t = Token(t.name, 'http://' + t)
         else:
             return LinkNode(t)
 
-
     def parse_atomics(self, tokens):
         collect = []
         while tokens:
                 break
         return collect
 
-
     def parse_italic(self, tokens, inner=False):
         t = tokens.pop(0)
         assert t.name == 'UNDERSCORE'
 
         return [Node('span', '_')] + collect
 
-
     def parse_bold(self, tokens, inner=False):
         t = tokens.pop(0)
         assert t.name == 'STAR' or t.name == 'ITEMSTAR'
 
         return [Node('span', '*')] + collect
 
-
     def parse_line(self, tokens):
         collect = []
         while tokens:
                 break
         return collect
 
-
     def parse_list(self, tokens):
         initial_indent = 0
         if tokens[0].name == 'INDENT':
                 break
         return [l]
 
-
     def parse_definition(self, tokens):
         initial_indent = 0
         if tokens[0].name == 'INDENT':
                 break
         return [dl]
 
-
     def parse_quote(self, tokens):
         initial_indent = 0
         if tokens[0].name == 'INDENT':
         quote.extend(self.parse_blocks(new_tokens))
         return [quote]
 
-
     def calculate_line_length(self, line):
         length = 0
         for i in line:
                 raise Exception(str(type(i)))
         return length
 
-
     def parse_paragraph(self, tokens):
         p = Node('p')
         shorts = []
         else:
             return []
 
-
     def parse_blocks(self, tokens):
         collect = []
         while tokens:
                 collect.extend(self.parse_paragraph(tokens))
         return collect
 
-
     def parse(self, s):
         if isinstance(s, str):
             s = s.decode(encoding)
         return finished
 
 
-
 if __name__ == '__main__':
     def parse_and_print(w, text):
         blocks = w.parse(text)