Andriy Kornatskyy avatar Andriy Kornatskyy committed 70c514c

Fixed PEP8 warnings.

Comments (0)

Files changed (16)

-syntax: glob                                                                   
-build/                                                                         
-dist/                                                                          
-env/                                                                           
-src/*.egg-info/                                                                
-.coverage                                                                      
-*.pyc                                                                          
-*.pyo                                                                          
-doc/_build
+syntax: glob
+build/
+dist/
+env/
+src/*.egg-info/
+.cache
+.coverage
+*.pyc
+*.pyo
+doc/_build
 clean:
 	find src/ -type d -name __pycache__ | xargs rm -rf
 	find src/ -name '*.py[co]' -delete
-	rm -rf dist/ build/ MANIFEST src/*.egg-info
+	rm -rf dist/ build/ MANIFEST src/*.egg-info .cache .coverage
 
 release:
 	$(PYTHON) setup.py -q bdist_egg
 upload-dir = doc/_build
 
 [pytest]
+pep8ignore =

src/wheezy/html/builder.py

         if self.formatted is None:
             self.format()
         return Widget(tag_name, self.name, self.formatted,
-                self.errors)
+                      self.errors)
 
     def error(self):
         if self.errors is None:

src/wheezy/html/ext/jinja2.py

 import re
 
 # from jinja2.ext import Extension
-Extension = __import__('jinja2.ext', None, None,
-            ['Extension']).Extension
+Extension = __import__('jinja2.ext', None, None, ['Extension']).Extension
 
 from wheezy.html.ext.lexer import InlinePreprocessor
 from wheezy.html.ext.lexer import Preprocessor
 class Jinja2Preprocessor(Preprocessor):
 
     def __init__(self,
-            variable_start_string=None,
-            variable_end_string=None):
+                 variable_start_string=None,
+                 variable_end_string=None):
         pattern = r'\s*\{\{((?P<expr>.+?)\.'\
             r'(?P<widget>%(widgets)s){1}\((?P<params>.*?)\)\s*'\
             r'(?P<expr_filter>(\|\s*[\w,\s]+?|\s*)))\}\}\s*'
         if variable_start_string:
             pattern = pattern.replace('\{\{',
-                    re.escape(variable_start_string))
+                                      re.escape(variable_start_string))
         if variable_end_string:
             pattern = pattern.replace('\}\}',
-                    re.escape(variable_end_string))
+                                      re.escape(variable_end_string))
         super(Jinja2Preprocessor, self).__init__(pattern)
 
-        attrs = ['EXPRESSION', 'ERROR', 'SELECT', 'INPUT', 'CHECKBOX',
-                    'MULTIPLE_CHECKBOX', 'MULTIPLE_HIDDEN', 'RADIO']
+        attrs = [
+            'EXPRESSION', 'ERROR', 'SELECT', 'INPUT', 'CHECKBOX',
+            'MULTIPLE_CHECKBOX', 'MULTIPLE_HIDDEN', 'RADIO'
+        ]
         c = self.__class__.__dict__
         for attr in attrs:
             self.__dict__[attr] = c[attr].replace(
-                    '{{', variable_start_string).replace(
+                '{{', variable_start_string).replace(
                     '}}', variable_end_string)
 
     EXPRESSION = '{{ %(expr)s%(expr_filter)s }}'
     def __init__(self, environment):
         super(WidgetExtension, self).__init__(environment)
         self.preprocessor = Jinja2Preprocessor(
-                variable_start_string=environment.variable_start_string,
-                variable_end_string=environment.variable_end_string)
+            variable_start_string=environment.variable_start_string,
+            variable_end_string=environment.variable_end_string)
 
     def preprocess(self, source, name, filename=None):
         return self.preprocessor(source)
         block_start_string = environment.block_start_string
         block_end_string = environment.block_end_string
         self.preprocessor = WhitespacePreprocessor(rules=[
-                (re.compile(r'^ \s+|\s+$', re.MULTILINE),
-                    r''),
-                (re.compile(r'>\s+<'),
-                    r'><'),
-                (re.compile(
-                    r'>\s+\{%'.replace('\{%', re.escape(block_start_string))),
-                    r'>{%'.replace('{%', block_start_string)),
-                (re.compile(
-                    r'%\}\s+<'.replace('%\}', re.escape(block_end_string))),
-                    r'%}<'.replace('%}', block_end_string)),
-            ])
+            (re.compile(r'^ \s+|\s+$', re.MULTILINE),
+                r''),
+            (re.compile(r'>\s+<'),
+                r'><'),
+            (re.compile(
+                r'>\s+\{%'.replace('\{%', re.escape(block_start_string))),
+                r'>{%'.replace('{%', block_start_string)),
+            (re.compile(
+                r'%\}\s+<'.replace('%\}', re.escape(block_end_string))),
+                r'%}<'.replace('%}', block_end_string)),
+        ])
 
     def preprocess(self, source, name, filename=None):
         return self.preprocessor(source)
 
 
 RE_INLINE = re.compile(r'{%\s*inline\s+("|\')(?P<path>.+?)\1\s*%}',
-        re.MULTILINE)
+                       re.MULTILINE)
 
 
 class InlineExtension(Extension):
         strategy = fallback and (
             lambda path: '{% include "' + path + '" %}') or None
         self.preprocessor = InlinePreprocessor(
-                RE_INLINE, searchpath, strategy)
+            RE_INLINE, searchpath, strategy)
 
     def __call__(self, environment):
         super(InlineExtension, self).__init__(environment)

src/wheezy/html/ext/lexer.py

     RADIO = None
     SELECT = None
     TEXTAREA = '<textarea id="%(id)s" name="%(name)s"%(attrs)s%(class)s>' \
-            '%(value)s</textarea>'
+        '%(value)s</textarea>'
 
     # region: preprocessing
 
         """
         value = parse_str_or_int(text)
         return value or self.EXPRESSION % {
-                        'expr': text,
-                        'expr_filter': expr_filter}
+            'expr': text,
+            'expr_filter': expr_filter}
 
     def join_attrs(self, kwargs):
         """ Joins ``kwargs`` as html attributes.
         """
         if class_:
             return self.ERROR_CLASS1 % {
-                    'name': name,
-                    'class': self.expression(class_)}
+                'name': name,
+                'class': self.expression(class_)}
         else:
             return self.ERROR_CLASS0 % {
-                    'name': name}
+                'name': name}
 
     # region: widgets
 
         """
         name = parse_name(expr)
         return self.HIDDEN % {
-                'name': name,
-                'value': self.expression(expr, expr_filter)}
+            'name': name,
+            'value': self.expression(expr, expr_filter)}
 
     def multiple_hidden(self, expr, params, expr_filter):
         """ Multiple HTML element input of type hidden.
         """
         """
         return self.select_helper(
-                expr, params, expr_filter, ' multiple="multiple"')
+            expr, params, expr_filter, ' multiple="multiple"')
 
     def select_helper(self, expr, params, expr_filter, select_type):
         """ HTML element select.

src/wheezy/html/ext/mako.py

 
 widget_preprocessor = MakoPreprocessor()
 whitespace_preprocessor = WhitespacePreprocessor(rules=[
-        (re.compile(r'^ \s+|\s+$', re.MULTILINE),
-            r''),
-        (re.compile(r'>\s+<'),
-            r'><'),
+    (re.compile(r'^ \s+|\s+$', re.MULTILINE),
+     r''),
+    (re.compile(r'>\s+<'),
+     r'><'),
 ])
 
 
 RE_INLINE = re.compile(r'<%inline\s+file=("|\')(?P<path>.+?)\1\s*/>',
-        re.MULTILINE)
+                       re.MULTILINE)
 
 
 def inline_preprocessor(directories, fallback=False):
         'shared/footer.html'
     """
     strategy = fallback and (
-            lambda path: '<%include file="' + path + '"/>') or None
+        lambda path: '<%include file="' + path + '"/>') or None
     return InlinePreprocessor(RE_INLINE, directories, strategy)

src/wheezy/html/ext/tenjin.py

 
 widget_preprocessor = TenjinPreprocessor()
 whitespace_preprocessor = WhitespacePreprocessor(rules=[
-        (re.compile(r'^ \s+|\s+$', re.MULTILINE),
-            r''),
-        (re.compile(r'(?<!\?)>\s+<(?!\?)'),
-            r'><'),
+    (re.compile(r'^ \s+|\s+$', re.MULTILINE),
+     r''),
+    (re.compile(r'(?<!\?)>\s+<(?!\?)'),
+     r'><'),
 ])
 
 
 RE_INLINE = re.compile(r'<\?py\s+inline\(("|\')(?P<path>.+?)\1\)\s*\?>',
-        re.MULTILINE)
+                       re.MULTILINE)
 
 
 def inline_preprocessor(directories, fallback=False):
         'shared/footer.html'
     """
     strategy = fallback and (
-            lambda path: '<?py include("' + path + '") ?>') or None
+        lambda path: '<?py include("' + path + '") ?>') or None
     return InlinePreprocessor(RE_INLINE, directories, strategy)

src/wheezy/html/ext/tests/test_jinja2.py

 
     def assert_render_equal(self, template, expected, **kwargs):
         assert_jinja2_equal({
-                'variable_start_string': '{{',
-                'variable_end_string': '}}'
+            'variable_start_string': '{{',
+            'variable_end_string': '}}'
         }, template, expected, **kwargs)
 
     HIDDEN = '{{ model.pref.hidden()|e }}'
 
     def assert_render_equal(self, template, expected, **kwargs):
         assert_jinja2_equal({
-                'variable_start_string': '${',
-                'variable_end_string': '}'
+            'variable_start_string': '${',
+            'variable_end_string': '}'
         }, template, expected, **kwargs)
 
     HIDDEN = '${model.pref.hidden()|e}'
         assert 'x' == self.preprocess('x  ')
         assert '><' == self.preprocess('  > < ')
         assert '>' + self.block_start_string == self.preprocess(
-                '>  ' + self.block_start_string)
+            '>  ' + self.block_start_string)
         assert self.block_end_string + '<' == self.preprocess(
-                self.block_end_string + '  <')
+            self.block_end_string + '  <')
 
 
 class Jinja2WhitespaceExtensionTestCase2(Jinja2WhitespaceExtensionTestCase):
 try:
     # from jinja2 import Environment
     Environment = __import__('jinja2', None, None,
-            ['Environment']).Environment
+                             ['Environment']).Environment
     from wheezy.html.ext.jinja2 import WidgetExtension
 
     def assert_jinja2_equal(options, text, expected, **kwargs):
         template = Environment(
-                extensions=[WidgetExtension],
-                **options
+            extensions=[WidgetExtension],
+            **options
         ).from_string(text)
         value = template.render(kwargs)
         assert expected == value

src/wheezy/html/ext/tests/test_lexer.py

         p = Preprocessor('%(widgets)s')
         assert 17 == len(p.widgets)
         assert 'checkbox|dropdown|emptybox|error|hidden|info|'\
-                'label|listbox|multiple_checkbox|multiple_hidden|'\
-                'multiple_select|password|radio|select|textarea|'\
-                'textbox|warning' == '|'.join(
-                        sorted(p.RE_WIDGETS.pattern.split('|')))
+            'label|listbox|multiple_checkbox|multiple_hidden|'\
+            'multiple_select|password|radio|select|textarea|'\
+            'textbox|warning' == '|'.join(
+                sorted(p.RE_WIDGETS.pattern.split('|')))
 
 
 class PreprocessorHelpersTestCase(unittest.TestCase):
 
         self.p.EXPRESSION = '%(expr)s%(expr_filter)s'
         assert ' autocomplete="off" disabled="${disabled}" ' \
-                'maxlength="100"' == self.p.join_attrs({
-                'autocomplete': 'off',
-                'maxlength': '100',
-                'disabled': '${disabled}'})
+            'maxlength="100"' == self.p.join_attrs({
+            'autocomplete': 'off',
+            'maxlength': '100',
+            'disabled': '${disabled}'})
 
     def test_error_class_no_class(self):
         """ Substitute ``name`` in case ``class_`` is undefined.
         """
         self.p.HIDDEN = '%(name)s %(value)s'
         assert 'pref model.pref|f' == self.p.hidden(
-                'model.pref', None, '|f')
+            'model.pref', None, '|f')
 
     def test_multiple_hidden(self):
         """ multiple_hidden widget
         """
         self.p.MULTIPLE_HIDDEN = '%(name)s %(value)s%(expr_filter)s'
         assert 'prefs model.prefs|f' == self.p.multiple_hidden(
-                'model.prefs', None, '|f')
+            'model.prefs', None, '|f')
 
     def test_label(self):
         """ label widget
             attrs =  autocomplete="off"
             class = user_name x
         """ == self.p.label('model.user_name',
-                '"User:", class="x", autocomplete="off"', '|f')
+                            '"User:", class="x", autocomplete="off"', '|f')
 
     def test_emptybox(self):
         """ emptybox widget
             attrs =  autocomplete="off"
             class = user_name x
         """ == self.p.emptybox('model.user_name',
-                'class="x", autocomplete="off"', '|f')
+                               'class="x", autocomplete="off"', '|f')
 
     def test_textbox(self):
         """ textbox widget
             attrs =  autocomplete="off"
             class = user_name x
         """ == self.p.textbox('model.user_name',
-                'class="x", autocomplete="off"', '|f')
+                              'class="x", autocomplete="off"', '|f')
 
     def test_password(self):
         """ password widget
             attrs =  autocomplete="off"
             class = user_pwd x
         """ == self.p.password('model.user_pwd',
-                'class="x", autocomplete="off"', '|f')
+                               'class="x", autocomplete="off"', '|f')
 
     def test_textarea(self):
         """ textarea widget
             attrs =  autocomplete="off" rows="9" cols="40"
             class = comment x
         """ == self.p.textarea('model.comment',
-                'class="x", autocomplete="off"', '|f')
+                               'class="x", autocomplete="off"', '|f')
 
     def test_checkbox(self):
         """ checkbox widget
             attrs =  autocomplete="off"
             class = accepts x
         """ == self.p.checkbox('model.accepts',
-                'class="x", autocomplete="off"', '|f')
+                               'class="x", autocomplete="off"', '|f')
 
     def test_multiple_checkbox(self):
         """ multiple_checkbox widget
             expr_filter = |f
             attrs =  cursor="auto"
             class = colors x
-        """ == self.p.multiple_checkbox('model.colors',
-                'class="x", cursor="auto", choices=${lst}', '|f')
+        """ == self.p.multiple_checkbox(
+            'model.colors',
+            'class="x", cursor="auto", choices=${lst}', '|f')
 
     def test_radio(self):
         """ radio widget
             attrs =  cursor="auto"
             class = yes_no x
         """ == self.p.radio('model.yes_no',
-                'class="x", cursor="auto", choices=${lst}', '|f')
+                            'class="x", cursor="auto", choices=${lst}', '|f')
 
     def test_dropdown(self):
         """ dropdown widget
             expr_filter = |f
             attrs =  cursor="auto"
             class = security_question x
-        """ == self.p.dropdown('model.security_question',
-                'class="x", cursor="auto", choices=${lst}', '|f')
+        """ == self.p.dropdown(
+            'model.security_question',
+            'class="x", cursor="auto", choices=${lst}', '|f')
 
     def test_listbox(self):
         """ listbox widget
             expr_filter = |f
             attrs =  cursor="auto"
             class = languages x
-        """ == self.p.listbox('model.languages',
-                'class="x", cursor="auto", choices=${lst}', '|f')
+        """ == self.p.listbox(
+            'model.languages',
+            'class="x", cursor="auto", choices=${lst}', '|f')
 
     def test_error(self):
         """ error widget
             attrs =  cursor="auto" class="error"
             expr_filter = |f
         """ == self.p.error('model.user_name',
-                'cursor="auto"', '|f')
+                            'cursor="auto"', '|f')
         assert """
             name = user_name
             attrs =  cursor="auto" class="error x"
             expr_filter = |f
         """ == self.p.error('model.user_name',
-                'class="x", cursor="auto"', '|f')
+                            'class="x", cursor="auto"', '|f')
         assert """
             name = __ERROR__
             attrs =  cursor="auto" class="error-message"
             expr_filter = |f
         """ == self.p.error('model',
-                'cursor="auto"', '|f')
+                            'cursor="auto"', '|f')
         assert """
             name = __ERROR__
             attrs =  cursor="auto" class="error-message x"
             expr_filter = |f
         """ == self.p.error('model',
-                'class="x", cursor="auto"', '|f')
+                            'class="x", cursor="auto"', '|f')
 
     def test_info(self):
         """ info widget
             info = model.username|f
             attrs =  cursor="auto" class="warning x"
         """ == self.p.warning('model.username',
-                'class="x", cursor="auto"', '|f')
+                              'class="x", cursor="auto"', '|f')
         assert """
             value = model
             info = model|f
 
     scm = sorted({
         'git': 'Git', 'hg': 'Mercurial', 'svn': 'SVN'
-        }.items(), key=itemgetter(1))
+    }.items(), key=itemgetter(1))
 
     def setUp(self):
         self.m = PreprocessorMixin.Dummy()
     def render(self, widget, html):
         """ hidden widget.
         """
-        self.assert_render_equal(widget, html,
-                model=self.m,
-                errors=self.e,
-                scm=self.scm,
-                message=(hasattr(self.m, 'message') and self.m.message or ''))
+        self.assert_render_equal(
+            widget, html, model=self.m, errors=self.e, scm=self.scm,
+            message=(hasattr(self.m, 'message') and self.m.message or ''))
 
     def test_hidden(self):
         """ hidden widget.
         """
         self.m.pref = 'ab<c>'
         self.render(self.HIDDEN,
-                '<input type="hidden" name="pref" value="ab&lt;c&gt;" />')
+                    '<input type="hidden" name="pref" value="ab&lt;c&gt;" />')
 
     def test_multiple_hidden(self):
         """ multiple_hidden widget.
         """
         self.m.prefs = ['a', 'b']
         self.render(self.MULTIPLE_HIDDEN,
-                '<input type="hidden" name="prefs" value="a" />'
-                '<input type="hidden" name="prefs" value="b" />')
+                    '<input type="hidden" name="prefs" value="a" />'
+                    '<input type="hidden" name="prefs" value="b" />')
 
     def test_label(self):
         """ label widget.
         """
         self.m.username = ''
         self.render(self.LABEL,
-                '<label for="username"><i>*</i>Username:</label>')
+                    '<label for="username"><i>*</i>Username:</label>')
         self.e['username'] = 'Error'
         self.render(self.LABEL,
-                '<label for="username" class="error">'
-                '<i>*</i>Username:</label>')
+                    '<label for="username" class="error">'
+                    '<i>*</i>Username:</label>')
 
     def test_emptybox(self):
         """ emptybox widget.
         """
         self.m.amount = 10
         self.render(self.EMPTYBOX,
-                '<input id="amount" name="amount" type="text" class="x" '
-                'value="10" />')
+                    '<input id="amount" name="amount" type="text" class="x" '
+                    'value="10" />')
         self.m.amount = 0
-        self.render(self.EMPTYBOX,
-                '<input id="amount" name="amount" type="text" class="x" />')
+        self.render(
+            self.EMPTYBOX,
+            '<input id="amount" name="amount" type="text" class="x" />')
         self.e['amount'] = 'Error'
         self.render(self.EMPTYBOX,
-                '<input id="amount" name="amount" type="text"'
-                ' class="error x" />')
+                    '<input id="amount" name="amount" type="text"'
+                    ' class="error x" />')
 
     def test_textbox(self):
         """ textbox widget.
         """
         self.m.username = 'John'
         self.render(self.TEXTBOX,
-                '<input id="username" name="username" type="text" '
-                'autocomplete="off" value="John" />')
+                    '<input id="username" name="username" type="text" '
+                    'autocomplete="off" value="John" />')
         self.m.username = ''
         self.render(self.TEXTBOX,
-                '<input id="username" name="username" type="text" '
-                'autocomplete="off" />')
+                    '<input id="username" name="username" type="text" '
+                    'autocomplete="off" />')
         self.e['username'] = 'Error'
         self.render(self.TEXTBOX,
-                '<input id="username" name="username" type="text" '
-                'autocomplete="off" class="error" />')
+                    '<input id="username" name="username" type="text" '
+                    'autocomplete="off" class="error" />')
 
     def test_password(self):
         """ password widget.
         """
         self.m.pwd = ''
         self.render(self.PASSWORD,
-                '<input id="pwd" name="pwd" type="password" />')
+                    '<input id="pwd" name="pwd" type="password" />')
         self.e['pwd'] = 'Error'
-        self.render(self.PASSWORD,
-                '<input id="pwd" name="pwd" type="password" class="error" />')
+        self.render(
+            self.PASSWORD,
+            '<input id="pwd" name="pwd" type="password" class="error" />')
 
     def test_textarea(self):
         """ textarea widget.
         """
         self.m.comment = 'x'
         self.render(self.TEXTAREA,
-                '<textarea id="comment" name="comment" '
-                'rows="9" cols="40">x</textarea>')
+                    '<textarea id="comment" name="comment" '
+                    'rows="9" cols="40">x</textarea>')
         self.e['comment'] = 'Error'
         self.render(self.TEXTAREA,
-                '<textarea id="comment" name="comment" '
-                'rows="9" cols="40" class="error">x</textarea>')
+                    '<textarea id="comment" name="comment" '
+                    'rows="9" cols="40" class="error">x</textarea>')
 
     def test_checkbox(self):
         """ checkbox widget.
         """
         self.m.remember_me = True
         self.render(self.CHECKBOX,
-                '<input id="remember-me" name="remember_me" '
-                'type="checkbox" value="1" checked="checked" />')
+                    '<input id="remember-me" name="remember_me" '
+                    'type="checkbox" value="1" checked="checked" />')
         self.m.remember_me = False
         self.render(self.CHECKBOX,
-                '<input id="remember-me" name="remember_me" '
-                'type="checkbox" value="1" />')
+                    '<input id="remember-me" name="remember_me" '
+                    'type="checkbox" value="1" />')
         self.e['remember_me'] = 'Error'
         self.render(self.CHECKBOX,
-                '<input id="remember-me" name="remember_me" '
-                'type="checkbox" value="1" class="error" />')
+                    '<input id="remember-me" name="remember_me" '
+                    'type="checkbox" value="1" class="error" />')
 
     def test_multiple_checkbox(self):
         """ multiple_checkbox widget.
         """
         self.m.scm = ['hg', 'git']
         self.render(self.MULTIPLE_CHECKBOX,
-                '<label><input id="scm" name="scm" type="checkbox" '
-                'value="1" checked="checked" />Git</label>'
-                '<label><input id="scm" name="scm" type="checkbox" '
-                'value="1" checked="checked" />Mercurial</label>'
-                '<label><input id="scm" name="scm" type="checkbox" '
-                'value="1" />SVN</label>')
+                    '<label><input id="scm" name="scm" type="checkbox" '
+                    'value="1" checked="checked" />Git</label>'
+                    '<label><input id="scm" name="scm" type="checkbox" '
+                    'value="1" checked="checked" />Mercurial</label>'
+                    '<label><input id="scm" name="scm" type="checkbox" '
+                    'value="1" />SVN</label>')
         self.m.scm = []
         self.render(self.MULTIPLE_CHECKBOX,
-                '<label><input id="scm" name="scm" type="checkbox" '
-                'value="1" />Git</label>'
-                '<label><input id="scm" name="scm" type="checkbox" '
-                'value="1" />Mercurial</label>'
-                '<label><input id="scm" name="scm" type="checkbox" '
-                'value="1" />SVN</label>')
+                    '<label><input id="scm" name="scm" type="checkbox" '
+                    'value="1" />Git</label>'
+                    '<label><input id="scm" name="scm" type="checkbox" '
+                    'value="1" />Mercurial</label>'
+                    '<label><input id="scm" name="scm" type="checkbox" '
+                    'value="1" />SVN</label>')
         self.e['scm'] = 'Error'
-        self.render(self.MULTIPLE_CHECKBOX,
-                '<label class="error"><input id="scm" name="scm" '
-                'type="checkbox" value="1" class="error" />Git</label>'
-                '<label class="error"><input id="scm" name="scm" '
-                'type="checkbox" value="1" class="error" />Mercurial</label>'
-                '<label class="error"><input id="scm" name="scm" '
-                'type="checkbox" value="1" class="error" />SVN</label>')
+        self.render(
+            self.MULTIPLE_CHECKBOX,
+            '<label class="error"><input id="scm" name="scm" '
+            'type="checkbox" value="1" class="error" />Git</label>'
+            '<label class="error"><input id="scm" name="scm" '
+            'type="checkbox" value="1" class="error" />Mercurial</label>'
+            '<label class="error"><input id="scm" name="scm" '
+            'type="checkbox" value="1" class="error" />SVN</label>')
 
     def test_radio(self):
         """ radio widget.
         """
         self.m.scm = 'hg'
         self.render(self.RADIO,
-                '<label><input type="radio" name="scm" value="git" />'
-                'Git</label>'
-                '<label><input type="radio" name="scm" value="hg" '
-                'checked="checked" />Mercurial</label>'
-                '<label><input type="radio" name="scm" value="svn" />'
-                'SVN</label>')
+                    '<label><input type="radio" name="scm" value="git" />'
+                    'Git</label>'
+                    '<label><input type="radio" name="scm" value="hg" '
+                    'checked="checked" />Mercurial</label>'
+                    '<label><input type="radio" name="scm" value="svn" />'
+                    'SVN</label>')
         self.m.scm = ''
         self.render(self.RADIO,
-                '<label><input type="radio" name="scm" value="git" />'
-                'Git</label>'
-                '<label><input type="radio" name="scm" value="hg" />'
-                'Mercurial</label>'
-                '<label><input type="radio" name="scm" value="svn" />'
-                'SVN</label>')
+                    '<label><input type="radio" name="scm" value="git" />'
+                    'Git</label>'
+                    '<label><input type="radio" name="scm" value="hg" />'
+                    'Mercurial</label>'
+                    '<label><input type="radio" name="scm" value="svn" />'
+                    'SVN</label>')
         self.e['scm'] = 'Error'
         self.render(self.RADIO,
-                '<label class="error"><input type="radio" name="scm" '
-                'value="git" class="error" />Git</label>'
-                '<label class="error"><input type="radio" name="scm" '
-                'value="hg" class="error" />Mercurial</label>'
-                '<label class="error"><input type="radio" name="scm" '
-                'value="svn" class="error" />SVN</label>')
+                    '<label class="error"><input type="radio" name="scm" '
+                    'value="git" class="error" />Git</label>'
+                    '<label class="error"><input type="radio" name="scm" '
+                    'value="hg" class="error" />Mercurial</label>'
+                    '<label class="error"><input type="radio" name="scm" '
+                    'value="svn" class="error" />SVN</label>')
 
     def test_dropdown(self):
         """ dropdown widget.
         """
         self.m.scm = 'hg'
-        self.render(self.DROPDOWN,
-                '<select id="scm" name="scm">'
-                '<option value="git">Git</option>'
-                '<option value="hg" selected="selected">Mercurial</option>'
-                '<option value="svn">SVN</option>'
-                '</select>')
+        self.render(
+            self.DROPDOWN,
+            '<select id="scm" name="scm">'
+            '<option value="git">Git</option>'
+            '<option value="hg" selected="selected">Mercurial</option>'
+            '<option value="svn">SVN</option>'
+            '</select>')
         self.m.scm = ''
         self.render(self.DROPDOWN,
-                '<select id="scm" name="scm">'
-                '<option value="git">Git</option>'
-                '<option value="hg">Mercurial</option>'
-                '<option value="svn">SVN</option>'
-                '</select>')
+                    '<select id="scm" name="scm">'
+                    '<option value="git">Git</option>'
+                    '<option value="hg">Mercurial</option>'
+                    '<option value="svn">SVN</option>'
+                    '</select>')
         self.e['scm'] = 'Error'
         self.render(self.DROPDOWN,
-                '<select id="scm" name="scm" class="error">'
-                '<option value="git">Git</option>'
-                '<option value="hg">Mercurial</option>'
-                '<option value="svn">SVN</option>'
-                '</select>')
+                    '<select id="scm" name="scm" class="error">'
+                    '<option value="git">Git</option>'
+                    '<option value="hg">Mercurial</option>'
+                    '<option value="svn">SVN</option>'
+                    '</select>')
 
     def test_listbox(self):
         """ listbox widget.
         """
         self.m.scm = 'hg'
-        self.render(self.LISTBOX,
-                '<select id="scm" name="scm" multiple="multiple" class="x">'
-                '<option value="git">Git</option>'
-                '<option value="hg" selected="selected">Mercurial</option>'
-                '<option value="svn">SVN</option>'
-                '</select>')
+        self.render(
+            self.LISTBOX,
+            '<select id="scm" name="scm" multiple="multiple" class="x">'
+            '<option value="git">Git</option>'
+            '<option value="hg" selected="selected">Mercurial</option>'
+            '<option value="svn">SVN</option>'
+            '</select>')
         self.m.scm = ''
-        self.render(self.LISTBOX,
-                '<select id="scm" name="scm" multiple="multiple" class="x">'
-                '<option value="git">Git</option>'
-                '<option value="hg">Mercurial</option>'
-                '<option value="svn">SVN</option>'
-                '</select>')
+        self.render(
+            self.LISTBOX,
+            '<select id="scm" name="scm" multiple="multiple" class="x">'
+            '<option value="git">Git</option>'
+            '<option value="hg">Mercurial</option>'
+            '<option value="svn">SVN</option>'
+            '</select>')
         self.e['scm'] = 'Error'
         self.render(self.LISTBOX,
-                '<select id="scm" name="scm" multiple="multiple" '
-                'class="error x">'
-                '<option value="git">Git</option>'
-                '<option value="hg">Mercurial</option>'
-                '<option value="svn">SVN</option>'
-                '</select>')
+                    '<select id="scm" name="scm" multiple="multiple" '
+                    'class="error x">'
+                    '<option value="git">Git</option>'
+                    '<option value="hg">Mercurial</option>'
+                    '<option value="svn">SVN</option>'
+                    '</select>')
 
     def test_attribute_error(self):
         """ attribute error widget.
         self.render(self.GENERAL_ERROR, '')
         self.e['__ERROR__'] = ['Error1', 'Error2']
         self.render(self.GENERAL_ERROR,
-                '<span class="error-message">Error2</span>')
+                    '<span class="error-message">Error2</span>')
 
     def test_attribute_info(self):
         """ attribute info widget.
         self.render(self.GENERAL_INFO, '')
         self.m.message = 'Message'
         self.render(self.GENERAL_INFO,
-                '<span class="info-message">Message</span>')
+                    '<span class="info-message">Message</span>')
 
     def test_attribute_warning(self):
         """ attribute warning widget.
         self.render(self.GENERAL_WARNING, '')
         self.m.message = 'Message'
         self.render(self.GENERAL_WARNING,
-                '<span class="warning-message">Message</span>')
+                    '<span class="warning-message">Message</span>')

src/wheezy/html/ext/tests/test_mako.py

 
 try:
     # from mako.template import Template
-    Template = __import__('mako.template', None, None,
-            ['Template']).Template
+    Template = __import__('mako.template', None, None, ['Template']).Template
     from wheezy.html.ext.mako import widget_preprocessor
 
     def assert_mako_equal(text, expected, **kwargs):

src/wheezy/html/ext/tests/test_template.py

 
     def assert_template_equal(text, expected, **kwargs):
         engine = Engine(
-                loader=DictLoader({
-                    'x': "@require(model, errors, message, scm)\n" + text}),
-                extensions=[CoreExtension, WidgetExtension])
+            loader=DictLoader({
+                'x': "@require(model, errors, message, scm)\n" + text}),
+            extensions=[CoreExtension, WidgetExtension])
         engine.global_vars.update({'h': html_escape})
         template = engine.get_template('x')
         value = template.render(kwargs)

src/wheezy/html/ext/tests/test_tenjin.py

 
 try:
     # from tenjin import Template
-    Template = __import__('tenjin', None, None,
-            ['Template']).Template
-
+    Template = __import__('tenjin', None, None, ['Template']).Template
     from tenjin.helpers import escape, to_str
     assert escape, to_str
     from wheezy.html.ext.tenjin import widget_preprocessor

src/wheezy/html/markup.py

         name = self.name
         attrs = self.attrs
         t = '<' + name + ' ' + ' '.join(
-                    [k.rstrip('_') + '="' + attrs[k] + '"'
-                        for k in attrs])
+            [k.rstrip('_') + '="' + attrs[k] + '"' for k in attrs])
         inner = self.inner
         if inner is None:
             return t + ' />'

src/wheezy/html/utils.py

         >>> html_escape('&<>"\\'')
         "&amp;&lt;&gt;&quot;\'"
     """
-    return s.replace('&', '&amp;').replace('<', '&lt;'
-            ).replace('>', '&gt;').replace('"', '&quot;')
+    return s.replace('&', '&amp;').replace('<', '&lt;').replace(
+        '>', '&gt;').replace('"', '&quot;')
 
 
 html_id = lambda name: name.replace('_', '-')
                 formatter_name = type(value[0]).__name__
                 format_provider = format_providers[formatter_name]
             return tuple(format_provider(item, format_spec)
-                    for item in value)
+                         for item in value)
         except IndexError:
             return tuple([])
     else:
 
 
 format_providers = {
-        'str': lambda value, format_spec: html_escape(str_type(value)),
-        'unicode': lambda value, format_spec: html_escape(value),
-        'int': str_format_provider,
-        'Decimal': str_format_provider,
-        'bool': str_format_provider,
-        'float': str_format_provider,
-        'date': date_format_provider,
-        'time': lambda value, format_spec: value.strftime(
-            str(format_spec or '%H:%M')),
-        'datetime': datetime_format_provider,
-        'NoneType': lambda value, format_spec: ''
+    'str': lambda value, format_spec: html_escape(str_type(value)),
+    'unicode': lambda value, format_spec: html_escape(value),
+    'int': str_format_provider,
+    'Decimal': str_format_provider,
+    'bool': str_format_provider,
+    'float': str_format_provider,
+    'date': date_format_provider,
+    'time': lambda value, format_spec: value.strftime(
+        str(format_spec or '%H:%M')),
+    'datetime': datetime_format_provider,
+    'NoneType': lambda value, format_spec: ''
 }

src/wheezy/html/widgets.py

         <input type="hidden" name="pref" value="abc" />
     """
     return Tag('input', None, {
-            'name': name,
-            'type': 'hidden',
-            'value': value
+        'name': name,
+        'type': 'hidden',
+        'value': value
     })
 
 
             value="79053" name="zip_code" />
     """
     tag_attrs = {
-            'id': html_id(name),
-            'name': name,
-            'type': 'text'
+        'id': html_id(name),
+        'name': name,
+        'type': 'text'
     }
     if value:
         tag_attrs['value'] = value
             name="zip_code" />
     """
     tag_attrs = {
-            'id': html_id(name),
-            'name': name,
-            'type': 'text'
+        'id': html_id(name),
+        'name': name,
+        'type': 'text'
     }
     if value not in (None, ''):
         tag_attrs['value'] = value
             name="passwd" />
     """
     tag_attrs = {
-            'id': html_id(name),
-            'name': name,
-            'type': 'password'
+        'id': html_id(name),
+        'name': name,
+        'type': 'password'
     }
     if value not in (None, ''):
         tag_attrs['value'] = value
             id="message-text"></textarea>
     """
     tag_attrs = {
-            'id': html_id(name),
-            'name': name,
-            'rows': '9',
-            'cols': '40'
+        'id': html_id(name),
+        'name': name,
+        'rows': '9',
+        'cols': '40'
     }
     if attrs:
         tag_attrs.update(attrs)
             value="1" class="b" />
      """
     tag_attrs = {
-            'id': html_id(name),
-            'name': name,
-            'type': 'checkbox',
-            'value': '1'
+        'id': html_id(name),
+        'name': name,
+        'type': 'checkbox',
+        'value': '1'
     }
     if checked == 'True':
         tag_attrs['checked'] = 'checked'
     append = elements.append
     for key, text in choices:
         tag_attrs = {
-                'name': name,
-                'type': 'checkbox',
-                'value': key
+            'name': name,
+            'type': 'checkbox',
+            'value': key
         }
         if key in value:
             tag_attrs['checked'] = 'checked'
         if attrs:
             tag_attrs.update(attrs)
         append(Tag('label',
-            Fragment((Tag('input', None, tag_attrs), text)), attrs))
+                   Fragment((Tag('input', None, tag_attrs), text)), attrs))
     return Fragment(elements)
 
 
         <label class="inline" for="zip-code">Zip Code</label>
     """
     tag_attrs = {
-            'for': html_id(name)
+        'for': html_id(name)
     }
     if attrs:
         tag_attrs.update(attrs)
     for key, text in choices:
         if key == value:
             tag_attrs = {
-                    'value': key,
-                    'selected': 'selected'
+                'value': key,
+                'selected': 'selected'
             }
         else:
             tag_attrs = {
-                    'value': key
+                'value': key
             }
         append(Tag('option', text, tag_attrs))
     tag_attrs = {
-            'id': html_id(name),
-            'name': name
+        'id': html_id(name),
+        'name': name
     }
     if attrs:
         tag_attrs.update(attrs)
     for key, text in choices:
         if key in value:
             tag_attrs = {
-                    'value': key,
-                    'selected': 'selected'
+                'value': key,
+                'selected': 'selected'
             }
         else:
             tag_attrs = {
-                    'value': key
+                'value': key
             }
         append(Tag('option', text, tag_attrs))
     tag_attrs = {
-            'id': html_id(name),
-            'name': name,
-            'multiple': 'multiple'
+        'id': html_id(name),
+        'name': name,
+        'multiple': 'multiple'
     }
     if attrs:
         tag_attrs.update(attrs)
     append = elements.append
     for key, text in choices:
         tag_attrs = {
-                'name': name,
-                'type': 'radio',
-                'value': key
+            'name': name,
+            'type': 'radio',
+            'value': key
         }
         if key == value:
             tag_attrs['checked'] = 'checked'
         if attrs:
             tag_attrs.update(attrs)
         append(Tag('label',
-            Fragment((Tag('input', None, tag_attrs), text)), attrs))
+                   Fragment((Tag('input', None, tag_attrs), text)), attrs))
     return Fragment(elements)
 
 default = {
-        'hidden': hidden,
-        'multiple_hidden': multiple_hidden,
-        'emptybox': emptybox,
-        'textbox': textbox,
-        'password': password,
-        'textarea': textarea,
-        'checkbox': checkbox,
-        'multiple_checkbox': multiple_checkbox,
-        'label': label,
-        'dropdown': dropdown,
-        'select': dropdown,
-        'listbox': listbox,
-        'multiple_select': listbox,
-        'radio': radio
+    'hidden': hidden,
+    'multiple_hidden': multiple_hidden,
+    'emptybox': emptybox,
+    'textbox': textbox,
+    'password': password,
+    'textarea': textarea,
+    'checkbox': checkbox,
+    'multiple_checkbox': multiple_checkbox,
+    'label': label,
+    'dropdown': dropdown,
+    'select': dropdown,
+    'listbox': listbox,
+    'multiple_select': listbox,
+    'radio': radio
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.