Andriy Kornatskyy avatar Andriy Kornatskyy committed 6ed704c

Fixed PEP8 warnings.

Comments (0)

Files changed (39)

 dist/
 env/
 src/*.egg-info/
+.cache
 .coverage
 *.pyc
 *.pyo
 clean:
 	find src/ demos/ -type d -name __pycache__ | xargs rm -rf
 	find src/ demos/ -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

demos/hello/benchmark_hello.py

         p = Benchmark((
             self.test_welcome,
             self.test_home
-            ), 20000)
+        ), 20000)
         p.report('hello', baselines={
-                'test_welcome': 1.0,
-                'test_home': 0.9
+            'test_welcome': 1.0,
+            'test_home': 0.9
         })

demos/hello/hello.py

 
 
 all_urls = [
-        url('', WelcomeHandler, name='default'),
-        url('welcome', welcome, name='welcome')
+    url('', WelcomeHandler, name='default'),
+    url('welcome', welcome, name='welcome')
 ]
 
 
 options = {}
 main = WSGIApplication(
-        middleware=[
-            bootstrap_defaults(url_mapping=all_urls),
-            path_routing_middleware_factory
-        ],
-        options=options
+    middleware=[
+        bootstrap_defaults(url_mapping=all_urls),
+        path_routing_middleware_factory
+    ],
+    options=options
 )
 
 

demos/hello/helloworld.py

 cache = MemoryCache()
 cache_factory = lambda: cache
 public_cache_profile = CacheProfile(
-        'public', duration=timedelta(minutes=15), enabled=True)
+    'public', duration=timedelta(minutes=15), enabled=True)
 no_cache_profile = CacheProfile(
-        'none', no_store=True, enabled=True)
+    'none', no_store=True, enabled=True)
 
 
 class WelcomeHandler(BaseHandler):
     def get(self):
         response = HTTPResponse()
         response.write('Hello World! It is %s.'
-                % datetime.now().time().strftime('%H:%M:%S'))
+                       % datetime.now().time().strftime('%H:%M:%S'))
         return response
 
 
     def get(self):
         response = HTTPResponse()
         response.write('Hello World! It is %s.'
-                % datetime.now().time().strftime('%H:%M:%S'))
+                       % datetime.now().time().strftime('%H:%M:%S'))
         return response
 
 
 def now(request):
     response = HTTPResponse()
     response.write('It is %s.'
-                % datetime.now().time().strftime('%H:%M:%S'))
+                   % datetime.now().time().strftime('%H:%M:%S'))
     return response
 
 
 def now2(request):
     response = HTTPResponse()
     response.write('It is %s.'
-                % datetime.now().time().strftime('%H:%M:%S'))
+                   % datetime.now().time().strftime('%H:%M:%S'))
     return response
 
 
 all_urls = [
-        url('', WelcomeHandler),
-        url('welcome2', Welcome2Handler),
-        url('now', now),
-        url('now2', now2)
+    url('', WelcomeHandler),
+    url('welcome2', Welcome2Handler),
+    url('now', now),
+    url('now2', now2)
 ]
 
 options = {
-        'http_cache_factory': cache_factory
+    'http_cache_factory': cache_factory
 }
+
 main = WSGIApplication(
-        middleware=[
-            bootstrap_defaults(url_mapping=all_urls),
-            http_cache_middleware_factory,
-            http_error_middleware_factory,
-            path_routing_middleware_factory
-        ],
-        options=options
+    middleware=[
+        bootstrap_defaults(url_mapping=all_urls),
+        http_cache_middleware_factory,
+        http_error_middleware_factory,
+        path_routing_middleware_factory
+    ],
+    options=options
 )
 
 

demos/template/Makefile

 	find src/ -name '*.py[co]' -delete
 	find src/ -name '*.mo' -delete
 	find src/ -name '*.cache' -delete
-	rm -rf /tmp/mako_modules/
+	rm -rf /tmp/mako_modules/ .cache .coverage
 
 release:
 	$(PYTHON) setup.py -q egg_info sdist
 
 uwsgi:
 	echo $(TEMPLATE_ENGINE) ; export TEMPLATE_ENGINE=$(TEMPLATE_ENGINE) ; \
-	$(ENV)/bin/uwsgi --ini development.ini
+	../../uwsgi-1.3-snapshot2/uwsgi --ini development.ini
 
 gunicorn:
 	echo $(TEMPLATE_ENGINE) ; export TEMPLATE_ENGINE=$(TEMPLATE_ENGINE) ; \

demos/template/development.ini

 no-default-app = False
 auto-procname = True
 procname-prefix = MySite-
-limit-as = 70
+#limit-as = 70
 buffer-size = 2048
 post-buffering = 1024
 limit-post = 1024

demos/template/i18n/en/LC_MESSAGES/membership.po

 "The system was unable to create an account for you. Please try again later."
 
 #: src/membership/web/views.py:107 src/membership/web/views.py:112
+#: src/membership/web/views.py:114
 msgid ""
 "Your registration request has been queued. Please wait while your request "
 "will be processed. If your request fails please try again."

demos/template/i18n/membership.po

 "The system was unable to create an account for you. Please try again later."
 
 #: src/membership/web/views.py:107 src/membership/web/views.py:112
+#: src/membership/web/views.py:114
 msgid ""
 "Your registration request has been queued. Please wait while your request "
 "will be processed. If your request fails please try again."

demos/template/setup.cfg

 exclude-source-files=0
 
 [pytest]
+pep8ignore =

demos/template/src/app.py

 
 
 main = WSGIApplication(
-        middleware=[
-            bootstrap_defaults(url_mapping=all_urls),
-            http_cache_middleware_factory,
-            http_error_middleware_factory,
-            path_routing_middleware_factory
-        ],
-        options=options)
+    middleware=[
+        bootstrap_defaults(url_mapping=all_urls),
+        http_cache_middleware_factory,
+        http_error_middleware_factory,
+        path_routing_middleware_factory
+    ],
+    options=options)
 
 
 if __name__ == '__main__':

demos/template/src/config.py

 
 # HTTPCacheMiddleware
 options.update({
-        'http_cache_factory': cache_factory
+    'http_cache_factory': cache_factory
 })
 
 # Cache Profiles
 none_cache_profile = CacheProfile(
-        'none',
-        no_store=True,
-        enabled=True)
+    'none',
+    no_store=True,
+    enabled=True)
 static_cache_profile = CacheProfile(
-        'public',
-        duration=timedelta(minutes=15),
-        vary_environ=['HTTP_ACCEPT_ENCODING'],
-        namespace='static',
-        enabled=config.getboolean('cache-profile', 'static-enabled'))
+    'public',
+    duration=timedelta(minutes=15),
+    vary_environ=['HTTP_ACCEPT_ENCODING'],
+    namespace='static',
+    enabled=config.getboolean('cache-profile', 'static-enabled'))
 public_cache_profile = CacheProfile(
-        'server',
-        duration=timedelta(minutes=15),
-        vary_environ=['HTTP_ACCEPT_ENCODING'],
-        vary_cookies=['_a'],
-        no_store=True,
-        enabled=config.getboolean('cache-profile', 'public-enabled'))
+    'server',
+    duration=timedelta(minutes=15),
+    vary_environ=['HTTP_ACCEPT_ENCODING'],
+    vary_cookies=['_a'],
+    no_store=True,
+    enabled=config.getboolean('cache-profile', 'public-enabled'))
 
 # HTTPErrorMiddleware
 options.update({
-        'http_errors': defaultdict(lambda: 'http500', {
-            # HTTP status code: route name
-            400: 'http400',
-            401: 'signin',
-            403: 'http403',
-            404: 'http404',
-            405: 'default',
-            500: 'http500',
-        }),
+    'http_errors': defaultdict(lambda: 'http500', {
+        # HTTP status code: route name
+        400: 'http400',
+        401: 'signin',
+        403: 'http403',
+        404: 'http404',
+        405: 'default',
+        500: 'http500',
+    }),
 })
 
 # wheezy.security.crypto.Ticket
 options.update({
-        'CRYPTO_ENCRYPTION_KEY': config.get('crypto', 'encryption-key'),
-        'CRYPTO_VALIDATION_KEY': config.get('crypto', 'validation-key')
+    'CRYPTO_ENCRYPTION_KEY': config.get('crypto', 'encryption-key'),
+    'CRYPTO_VALIDATION_KEY': config.get('crypto', 'validation-key')
 })
 
 template_engine = os.getenv('TEMPLATE_ENGINE', 'tenjin')
 
     directories = ['content/templates-mako']
     render_template = MakoTemplate(
-            module_directory=config.get('mako', 'module-directory'),
-            filesystem_checks=config.getboolean('mako', 'filesystem-checks'),
-            directories=directories,
-            cache_factory=cache_factory,
-            preprocessor=[
-                inline_preprocessor(directories, config.getboolean(
-                    'mako', 'inline-preprocessor-fallback')),
-                widget_preprocessor,
-                whitespace_preprocessor,
-            ])
+        module_directory=config.get('mako', 'module-directory'),
+        filesystem_checks=config.getboolean('mako', 'filesystem-checks'),
+        directories=directories,
+        cache_factory=cache_factory,
+        preprocessor=[
+            inline_preprocessor(directories, config.getboolean(
+                'mako', 'inline-preprocessor-fallback')),
+            widget_preprocessor,
+            whitespace_preprocessor,
+        ])
 elif template_engine == 'tenjin':
     from wheezy.html.ext.tenjin import inline_preprocessor
     from wheezy.html.ext.tenjin import whitespace_preprocessor
 
     path = ['content/templates-tenjin']
     render_template = TenjinTemplate(
-            path=path,
-            pp=[
-                inline_preprocessor(path, config.getboolean(
-                    'tenjin', 'inline-preprocessor-fallback')),
-                widget_preprocessor,
-                whitespace_preprocessor,
-            ],
-            helpers={
-                'format_value': format_value
-            })
+        path=path,
+        pp=[
+            inline_preprocessor(path, config.getboolean(
+                'tenjin', 'inline-preprocessor-fallback')),
+            widget_preprocessor,
+            whitespace_preprocessor,
+        ],
+        helpers={
+            'format_value': format_value
+        })
 elif template_engine == 'jinja2':
     from jinja2 import Environment
     from jinja2 import FileSystemLoader
         auto_reload=config.get('jinja2', 'auto-reload'),
         extensions=[
             InlineExtension(searchpath, config.getboolean(
-                    'jinja2', 'inline-preprocessor-fallback')),
+                'jinja2', 'inline-preprocessor-fallback')),
             WidgetExtension,
             WhitespaceExtension
         ])
     from public import __version__
     searchpath = ['content/templates-wheezy']
     engine = Engine(
-            loader=uwsgi_autoreload(
-                FileLoader(searchpath),
-                signum=10,
-                enabled=config.getint('uwsgi', 'python-auto-reload') > 0
-            ),
-            extensions=[
-                CoreExtension,
-                WidgetExtension,
-                WhitespaceExtension,
-    ])
+        loader=uwsgi_autoreload(
+            FileLoader(searchpath),
+            signum=10,
+            enabled=config.getint('uwsgi', 'python-auto-reload') > 0
+        ),
+        extensions=[
+            CoreExtension,
+            WidgetExtension,
+            WhitespaceExtension,
+        ])
     engine.global_vars.update({
         'format_value': format_value,
         'h': html_escape,
 
 # BaseHandler
 options.update({
-        'translations_manager': TranslationsManager(
-            directories=['i18n'],
-            default_lang='en'),
+    'translations_manager': TranslationsManager(
+        directories=['i18n'],
+        default_lang='en'),
 
-        'render_template': render_template,
+    'render_template': render_template,
 
-        'ticket': Ticket(
-            max_age=config.getint('crypto', 'ticket-max-age'),
-            salt=config.get('crypto', 'ticket-salt'),
-            cypher=aes128,
-            digestmod=ripemd160 or sha256 or sha1,
-            options=options),
+    'ticket': Ticket(
+        max_age=config.getint('crypto', 'ticket-max-age'),
+        salt=config.get('crypto', 'ticket-salt'),
+        cypher=aes128,
+        digestmod=ripemd160 or sha256 or sha1,
+        options=options),
 
-        'AUTH_COOKIE': '_a',
-        'AUTH_COOKIE_DOMAIN': None,
-        'AUTH_COOKIE_PATH': '',
-        'AUTH_COOKIE_SECURE': False,
+    'AUTH_COOKIE': '_a',
+    'AUTH_COOKIE_DOMAIN': None,
+    'AUTH_COOKIE_PATH': '',
+    'AUTH_COOKIE_SECURE': False,
 
-        'XSRF_NAME': '_x',
-        'RESUBMISSION_NAME': '_c'
+    'XSRF_NAME': '_x',
+    'RESUBMISSION_NAME': '_c'
 })

demos/template/src/factory.py

     @attribute
     def membership(self):
         return MembershipService(
-                self.repository,
-                self.errors,
-                self.translations)
+            self.repository,
+            self.errors,
+            self.translations)
 
 
 class RepositoryFactory(object):
     @attribute
     def membership(self):
         return MembershipRepository(
-                MembershipPersistence(self.session),
-                self.cache)
+            MembershipPersistence(self.session),
+            self.cache)

demos/template/src/membership/repository/mock.py

 
 class MembershipRepository(IMembershipRepository):
     credentials = {
-            'demo': u('P@ssw0rd'),
-            'biz': u('P@ssw0rd')
+        'demo': u('P@ssw0rd'),
+        'biz': u('P@ssw0rd')
     }
     roles = {
-            'demo': tuple(['user']),
-            'biz': tuple(['business'])
+        'demo': tuple(['user']),
+        'biz': tuple(['business'])
     }
 
     def __init__(self, session):
 
     def authenticate(self, credential):
         return credential.password == self.credentials.get(
-                credential.username, None)
+            credential.username, None)
 
     def has_account(self, username):
         return username in self.credentials
         credential = registration.credential
         self.credentials[credential.username] = credential.password
         self.roles[credential.username] = tuple(
-                [registration.account.account_type])
+            [registration.account.account_type])
         return True

demos/template/src/membership/service/bridge.py

     @attribute
     def password_questions(self):
         return {
-                '1': self.gettext('Favorite number'),
-                '2': self.gettext('City of birth'),
-                '3': self.gettext('Favorite color')
+            '1': self.gettext('Favorite number'),
+            '2': self.gettext('City of birth'),
+            '3': self.gettext('Favorite color')
         }
 
     @attribute
     def account_types(self):
         return {
-                'user': self.gettext('User'),
-                'business': self.gettext('Business')
+            'user': self.gettext('User'),
+            'business': self.gettext('Business')
         }
 
     def authenticate(self, credential):

demos/template/src/membership/web/tests/benchmark_views.py

             self.test_signin,
             self.test_signup,
             self.test_signout,
-            ), 1000)
+        ), 1000)
         p.report('membership', baselines={
-                'test_signin': 1.0,
-                'test_signup': 0.89,
-                'test_signout': 4.32,
+            'test_signin': 1.0,
+            'test_signup': 0.89,
+            'test_signout': 4.32,
         })
 
 
             self.test_validation_error,
             self.test_unknown_user,
             self.test_xrsf_token_invalid
-            ), 200)
+        ), 200)
 
         p.report('signin', baselines={
-                'test_validation_error': 1.0,
-                'test_unknown_user': 1.0,
-                'test_xrsf_token_invalid': 0.94
+            'test_validation_error': 1.0,
+            'test_unknown_user': 1.0,
+            'test_xrsf_token_invalid': 0.94
         })
 
 
             self.test_validation_error,
             self.test_already_registered,
             self.test_resubmission_token_invalid,
-            ), 100)
+        ), 100)
 
         p.report('signup', baselines={
-                'test_validation_error': 1.0,
-                'test_already_registered': 1.0,
-                'test_resubmission_token_invalid': 1.05
+            'test_validation_error': 1.0,
+            'test_already_registered': 1.0,
+            'test_resubmission_token_invalid': 1.05
         })

demos/template/src/membership/web/tests/test_views.py

         """ Ensure signup page displays general error message.
         """
         errors = self.signup(
-                username='demo',
-                display_name='Demo',
-                email='demo@somewhere.com',
-                date_of_birth='1984/11/14',
-                password='P@ssw0rd',
-                confirm_password='P@ssw0rd',
-                answer='7')
+            username='demo',
+            display_name='Demo',
+            email='demo@somewhere.com',
+            date_of_birth='1984/11/14',
+            password='P@ssw0rd',
+            confirm_password='P@ssw0rd',
+            answer='7')
         assert not errors
         assert AUTH_COOKIE not in self.client.cookies
         assert 'class="error-message"' in self.client.content
             user is registered and logged in.
         """
         errors = self.signup(
-                username='john',
-                display_name='John Smith',
-                email='john@somewhere.com',
-                date_of_birth='1987/2/7',
-                password='P@ssw0rd',
-                confirm_password='P@ssw0rd',
-                answer='7')
+            username='john',
+            display_name='John Smith',
+            email='john@somewhere.com',
+            date_of_birth='1987/2/7',
+            password='P@ssw0rd',
+            confirm_password='P@ssw0rd',
+            answer='7')
         assert not errors
         assert 200 == self.client.follow()
         assert AUTH_COOKIE in self.client.cookies

demos/template/src/membership/web/views.py

     def model(self):
         return attrdict({
             'remember_me': False
-            })
+        })
 
     @attribute
     def translation(self):
         if self.principal:
             return self.redirect_for('default')
         credential = credential or Credential()
-        return self.render_response('membership/signin.html',
-                        credential=credential,
-                        model=self.model)
+        return self.render_response(
+            'membership/signin.html',
+            credential=credential,
+            model=self.model)
 
     def post(self):
         if not self.validate_xsrf_token():
             credential.password = u('')
             return self.get(credential)
         self.principal = Principal(
-                id=credential.username,
-                alias=credential.username,
-                roles=tuple(self.factory.membership.roles(
-                    credential.username)))
+            id=credential.username,
+            alias=credential.username,
+            roles=tuple(self.factory.membership.roles(
+                credential.username)))
         del self.xsrf_token
         return self.see_other_for('default')
 
             'password': u(''),
             'confirm_password': u(''),
             'questionid': '1'
-            })
+        })
 
     @attribute
     def translation(self):
         if self.principal:
             return self.redirect_for('default')
         registration = registration or Registration()
-        return self.render_response('membership/signup.html',
-                model=self.model,
-                registration=registration,
-                account=registration.account,
-                credential=registration.credential,
-                questions=sorted(
-                    self.factory.membership.password_questions.items(),
-                    key=itemgetter(1)),
-                account_types=sorted(
-                    self.factory.membership.account_types.items(),
-                    key=itemgetter(1)))
+        return self.render_response(
+            'membership/signup.html',
+            model=self.model,
+            registration=registration,
+            account=registration.account,
+            credential=registration.credential,
+            questions=sorted(
+                self.factory.membership.password_questions.items(),
+                key=itemgetter(1)),
+            account_types=sorted(
+                self.factory.membership.account_types.items(),
+                key=itemgetter(1)))
 
     def post(self):
         if not self.validate_resubmission():
             self.error(self._('Your registration request has been queued. '
-                    'Please wait while your request will be processed. '
-                    'If your request fails please try again.'))
+                              'Please wait while your request will be '
+                              'processed. If your request fails please '
+                              'try again.'))
             return self.get()
         registration = Registration()
         if (not self.try_update_model(self.model)
             self.model.confirm_password = u('')
             return self.get(registration)
         self.principal = Principal(
-                id=registration.credential.username,
-                alias=registration.account.display_name,
-                roles=tuple(self.factory.membership.roles(
-                    registration.credential.username)))
+            id=registration.credential.username,
+            alias=registration.account.display_name,
+            roles=tuple(self.factory.membership.roles(
+                registration.credential.username)))
         del self.resubmission
         return self.see_other_for('default')

demos/template/src/public/web/tests/benchmark_views.py

             self.test_static_file_forbidden,
             self.test_static_file_gzip,
             self.test_head_static_file,
-            ), 1000)
+        ), 1000)
         p.report('public', baselines={
-                'test_home': 1.0,
-                'test_about': 0.95,
-                'test_error_400': 0.95,
-                'test_error_403': 0.95,
-                'test_error_404': 0.95,
-                'test_static_files': 2.17,
-                'test_static_file_not_found': 2.1,
-                'test_static_file_forbidden': 2.3,
-                'test_static_file_gzip': 11.4,
-                'test_head_static_file': 12.5,
+            'test_home': 1.0,
+            'test_about': 0.95,
+            'test_error_400': 0.95,
+            'test_error_403': 0.95,
+            'test_error_404': 0.95,
+            'test_static_files': 2.17,
+            'test_static_file_not_found': 2.1,
+            'test_static_file_forbidden': 2.3,
+            'test_static_file_gzip': 11.4,
+            'test_head_static_file': 12.5,
         })

demos/template/src/public/web/tests/test_views.py

         """ Ensure static content is served.
         """
         for static_file in [
-                '/favicon.ico',
-                '/static/css/site.css',
-                '/static/img/error.png',
-                '/static/js/core.js',
-                '/static/js/autocomplete.js',
-                '/static/js/jquery-1.7.1.min.js',
-                ]:
+            '/favicon.ico',
+            '/static/css/site.css',
+            '/static/img/error.png',
+            '/static/js/core.js',
+            '/static/js/autocomplete.js',
+            '/static/js/jquery-1.7.1.min.js',
+        ]:
             assert 200 == self.client.get(static_file)
 
     def test_static_file_not_found(self):

demos/template/src/public/web/urls.py

 
 
 server_cache = lambda handler: response_cache(public_cache_profile)(
-        response_transforms(gzip_transform(compress_level=9))(handler))
+    response_transforms(gzip_transform(compress_level=9))(handler))
 
 public_urls = [
     url('home', server_cache(home), name='home'),

demos/template/src/urls.py

 locale_pattern = '{locale:(en|ru)}/'
 locale_defaults = {'locale': 'en'}
 static_files = response_cache(static_cache_profile)(
-        response_transforms(gzip_transform(compress_level=6))(
-            file_handler(
-                root='content/static/',
-                age=timedelta(hours=1))))
+    response_transforms(gzip_transform(compress_level=6))(
+        file_handler(
+            root='content/static/',
+            age=timedelta(hours=1))))
 
 locale_urls = public_urls + membership_urls
 locale_urls.append(('error/', error_urls, locale_defaults))
 all_urls = [
-        url('',
-            template_handler('public/home.html'),
-            locale_defaults,
-            name='default'),
-        (locale_pattern, locale_urls, locale_defaults),
-        url('static/{path:any}', static_files, name='static'),
-        url('favicon.ico', static_files, {'path': 'img/favicon.ico'})
+    url('',
+        template_handler('public/home.html'),
+        locale_defaults,
+        name='default'),
+    (locale_pattern, locale_urls, locale_defaults),
+    url('static/{path:any}', static_files, name='static'),
+    url('favicon.ico', static_files, {'path': 'img/favicon.ico'})
 ]
 upload-dir = doc/_build
 
 [pytest]
+pep8ignore =

src/wheezy/web/handlers/base.py

 from wheezy.core.uuid import UUID_EMPTY
 from wheezy.core.uuid import parse_uuid
 from wheezy.core.uuid import shrink_uuid
-from wheezy.html import widget
 from wheezy.http import HTTPCookie
 from wheezy.http import HTTPResponse
 from wheezy.http import ajax_redirect
     @attribute
     def context(self):
         return {
-                'errors': self.errors,
-                'locale': self.locale,
-                'principal': self.principal,
-                'translations': self.translations
+            'errors': self.errors,
+            'locale': self.locale,
+            'principal': self.principal,
+            'translations': self.translations
         }
 
     # region: routing
 
     def path_for(self, name, **kwargs):
         return self.request.root_path + self.options['path_for'](
-                name, **dict(self.route_args, **kwargs))
+            name, **dict(self.route_args, **kwargs))
 
     def absolute_url_for(self, name, **kwargs):
         parts = self.request.urlparts
             return ajax_redirect(
                 self.absolute_url_for(name, **kwargs))
         return redirect(
-                self.absolute_url_for(name, **kwargs))
+            self.absolute_url_for(name, **kwargs))
 
     def see_other_for(self, name, **kwargs):
         if self.request.ajax:
             return ajax_redirect(
                 self.absolute_url_for(name, **kwargs))
         return see_other(
-                self.absolute_url_for(name, **kwargs))
+            self.absolute_url_for(name, **kwargs))
 
     # region: i18n
 
 
     def try_update_model(self, model, values=None):
         return try_update_model(
-                model, values or self.request.form, self.errors,
-                self.translations['validation'])
+            model, values or self.request.form, self.errors,
+            self.translations['validation'])
 
     # region: templates
 
 
     def render_template(self, template_name, **kwargs):
         return self.options['render_template'](
-                template_name, dict(self.helpers, **kwargs))
+            template_name, dict(self.helpers, **kwargs))
 
     def render_response(self, template_name, **kwargs):
         options = self.options
         response = HTTPResponse(options['CONTENT_TYPE'], options['ENCODING'])
         response.write(options['render_template'](
-                template_name, dict(self.helpers, **kwargs)))
+            template_name, dict(self.helpers, **kwargs)))
         return response
 
     # region: json
             return self.__principal
         principal = None
         auth_cookie = self.request.cookies.get(
-                self.options['AUTH_COOKIE'], None)
+            self.options['AUTH_COOKIE'], None)
         if auth_cookie is not None:
             auth_ticket = self.ticket
-            ticket, time_left = auth_ticket.decode(
-                    auth_cookie
-            )
+            ticket, time_left = auth_ticket.decode(auth_cookie)
             if ticket:
                 principal = Principal.load(ticket)
                 if time_left < auth_ticket.max_age / 2:
         if xsrf_name in form:
             xsrf_token = form[xsrf_name][-1]
             return xsrf_token == self.xsrf_token \
-                    and parse_uuid(xsrf_token) != UUID_EMPTY
+                and parse_uuid(xsrf_token) != UUID_EMPTY
         else:
             self.delxsrf_token()
             return False
 
     def xsrf_widget(self):
-        return '<input type="hidden" name="' + self.options['XSRF_NAME'] \
-                + '" value="' + self.xsrf_token + '" />'
+        return '<input type="hidden" name="' + self.options['XSRF_NAME'] + \
+            '" value="' + self.xsrf_token + '" />'
 
     # region: resubmission
 
         if self.request.ajax:
             return ''
         return '<input type="hidden" name="' + \
-                self.options['RESUBMISSION_NAME'] \
-                + '" value="' + self.resubmission + '" />'
+            self.options['RESUBMISSION_NAME'] + \
+            '" value="' + self.resubmission + '" />'
 
 
 def redirect_handler(route_name, **route_args):
     """ Redirects to given route name (HTTP status code 302).
     """
-    return lambda request: RedirectRouteHandler(request,
-            route_name,
-            **route_args)
+    return lambda request: RedirectRouteHandler(
+        request, route_name, **route_args)
 
 
 class RedirectRouteHandler(BaseHandler):
     """ Performs permanent redirect (HTTP status code 301) to given route
         name.
     """
-    return lambda request: PermanentRedirectRouteHandler(request,
-            route_name,
-            **route_args)
+    return lambda request: PermanentRedirectRouteHandler(
+        request, route_name, **route_args)
 
 
 class PermanentRedirectRouteHandler(BaseHandler):
 
     def get(self):
         return permanent_redirect(
-                self.absolute_url_for(self.route_name, **self.route_args))
+            self.absolute_url_for(self.route_name, **self.route_args))
 
     def post(self):
         return permanent_redirect(
-                self.absolute_url_for(self.route_name, **self.route_args))
+            self.absolute_url_for(self.route_name, **self.route_args))

src/wheezy/web/handlers/file.py

     assert os.path.isdir(abspath)
     assert age is None or isinstance(age, timedelta)
     return lambda request: FileHandler(
-            request,
-            root=abspath,
-            age=age)
+        request,
+        root=abspath,
+        age=age)
 
 
 class FileHandler(MethodHandler):

src/wheezy/web/handlers/template.py

     """ Serves templates that does not require up front data processing.
     """
     return lambda request: TemplateHandler(
-            request,
-            template_name=template_name,
-            status_code=status_code)
+        request,
+        template_name=template_name,
+        status_code=status_code)
 
 
 class TemplateHandler(BaseHandler):

src/wheezy/web/handlers/tests/test_base.py

         from wheezy.web.handlers.base import BaseHandler
         from wheezy.web.handlers.method import handler_factory
         self.options = {
-                'AUTH_COOKIE': '_a',
-                'AUTH_COOKIE_PATH': 'members',
-                'AUTH_COOKIE_DOMAIN': 'python.org',
-                'AUTH_COOKIE_SECURE': True,
-                'HTTP_COOKIE_SECURE': False,
-                'HTTP_COOKIE_HTTPONLY': False,
-                'translations_manager': {'en': 'translations'}
+            'AUTH_COOKIE': '_a',
+            'AUTH_COOKIE_PATH': 'members',
+            'AUTH_COOKIE_DOMAIN': 'python.org',
+            'AUTH_COOKIE_SECURE': True,
+            'HTTP_COOKIE_SECURE': False,
+            'HTTP_COOKIE_HTTPONLY': False,
+            'translations_manager': {'en': 'translations'}
         }
         self.mock_request = Mock()
         self.mock_request.options = self.options
         self.mock_request.root_path = 'my_site/'
         self.mock_request.cookies = {}
         self.mock_request.urlparts = urlparts(
-                scheme='https', netloc='python.org')
+            scheme='https', netloc='python.org')
         self.handler = handler_factory(BaseHandler, self.mock_request)
         assert isinstance(self.handler, BaseHandler)
 
         """ context
         """
         context = self.handler.context
-        assert ('errors', 'locale', 'principal',
-                'translations') == tuple(sorted(context.keys()))
+        assert ('errors', 'locale', 'principal', 'translations') \
+            == tuple(sorted(context.keys()))
 
 
 class BaseHandlerRoutingTestCase(unittest.TestCase):
         self.mock_request.method = 'GET'
         self.mock_request.root_path = 'my_site/'
         self.mock_request.urlparts = urlparts(
-                scheme='https', netloc='python.org')
+            scheme='https', netloc='python.org')
         self.handler = handler_factory(BaseHandler, self.mock_request)
         assert isinstance(self.handler, BaseHandler)
 
         """ Translations returned per current locale.
         """
         translations_manager = {
-                'en': 'en-trans',
-                'uk': 'uk-trans'
+            'en': 'en-trans',
+            'uk': 'uk-trans'
         }
         self.handler.route_args['locale'] = 'uk'
         self.options['translations_manager'] = translations_manager
         """
         from wheezy.core.i18n import null_translations
         translations_manager = {
-                'en': {
-                    'validation': null_translations
-                }
+            'en': {
+                'validation': null_translations
+            }
         }
         self.handler.route_args['locale'] = 'en'
         self.options['translations_manager'] = translations_manager
         self.mock_request.form = {
-                'name': ['test']
+            'name': ['test']
         }
         model = {
-                'name': ''
+            'name': ''
         }
         assert True == self.handler.try_update_model(model)
         assert 'test' == model['name']
         from wheezy.web.handlers.base import BaseHandler
         from wheezy.web.handlers.method import handler_factory
         self.options = {
-                'AUTH_COOKIE': '_a'
+            'AUTH_COOKIE': '_a'
         }
         self.mock_request = Mock()
         self.mock_request.options = self.options
     def test_helpers(self):
         """ template helpers.
         """
-        assert ('_', 'absolute_url_for', 'errors', 'path_for',
-                'principal', 'resubmission', 'route_args', 'xsrf'
+        assert (
+            '_', 'absolute_url_for', 'errors', 'path_for',
+            'principal', 'resubmission', 'route_args', 'xsrf'
         ) == tuple(sorted(self.handler.helpers.keys()))
 
     def test_render_template(self):
             return 'html'
         self.options['render_template'] = render_template
         assert 'html' == self.handler.render_template(
-                'signin.html', test=10)
+            'signin.html', test=10)
 
     def test_render_response(self):
         """ render_response.
         """
         mock_render_template = Mock(return_value='html')
         self.options.update({
-                'render_template': mock_render_template,
-                'CONTENT_TYPE': 'text/plain',
-                'ENCODING': 'UTF-8'
+            'render_template': mock_render_template,
+            'CONTENT_TYPE': 'text/plain',
+            'ENCODING': 'UTF-8'
         })
         response = self.handler.render_response('signin.html')
         assert mock_render_template.called
         from wheezy.web.handlers.base import BaseHandler
         from wheezy.web.handlers.method import handler_factory
         self.options = {
-                'AUTH_COOKIE': '_a',
-                'AUTH_COOKIE_PATH': 'members',
-                'AUTH_COOKIE_DOMAIN': 'python.org',
-                'AUTH_COOKIE_SECURE': True,
-                'HTTP_COOKIE_SECURE': False,
-                'HTTP_COOKIE_HTTPONLY': False
+            'AUTH_COOKIE': '_a',
+            'AUTH_COOKIE_PATH': 'members',
+            'AUTH_COOKIE_DOMAIN': 'python.org',
+            'AUTH_COOKIE_SECURE': True,
+            'HTTP_COOKIE_SECURE': False,
+            'HTTP_COOKIE_HTTPONLY': False
         }
         self.mock_request = Mock()
         self.mock_request.options = self.options
         from wheezy.web.handlers.base import BaseHandler
         from wheezy.web.handlers.method import handler_factory
         self.options = {
-                'XSRF_NAME': '_x'
+            'XSRF_NAME': '_x'
         }
         self.mock_request = Mock()
         self.mock_request.options = self.options
         """
         from wheezy.web.handlers import base
         self.options.update({
-                'HTTP_COOKIE_DOMAIN': None,
-                'HTTP_COOKIE_SECURE': True
+            'HTTP_COOKIE_DOMAIN': None,
+            'HTTP_COOKIE_SECURE': True
         })
         patcher = patch.object(base, 'shrink_uuid')
         mock_shrink_uuid = patcher.start()
         """ delxsrf_token.
         """
         self.options.update({
-                'HTTP_COOKIE_DOMAIN': None,
-                'HTTP_COOKIE_SECURE': True,
-                'HTTP_COOKIE_HTTPONLY': True
+            'HTTP_COOKIE_DOMAIN': None,
+            'HTTP_COOKIE_SECURE': True,
+            'HTTP_COOKIE_HTTPONLY': True
         })
         self.handler.delxsrf_token()
         assert 1 == len(self.handler.cookies)
             submitted.
         """
         self.options.update({
-                'HTTP_COOKIE_DOMAIN': None,
-                'HTTP_COOKIE_SECURE': True,
-                'HTTP_COOKIE_HTTPONLY': True
+            'HTTP_COOKIE_DOMAIN': None,
+            'HTTP_COOKIE_SECURE': True,
+            'HTTP_COOKIE_HTTPONLY': True
         })
         self.mock_request.form = {}
         assert not self.handler.validate_xsrf_token()
         from wheezy.web.handlers.base import BaseHandler
         from wheezy.web.handlers.method import handler_factory
         self.options = {
-                'RESUBMISSION_NAME': '_r'
+            'RESUBMISSION_NAME': '_r'
         }
         self.mock_request = Mock()
         self.mock_request.options = self.options
         """ XSRF cookie was not supplied with request.
         """
         self.options.update({
-                'HTTP_COOKIE_DOMAIN': None,
-                'HTTP_COOKIE_SECURE': True,
-                'HTTP_COOKIE_HTTPONLY': True
+            'HTTP_COOKIE_DOMAIN': None,
+            'HTTP_COOKIE_SECURE': True,
+            'HTTP_COOKIE_HTTPONLY': True
         })
         assert '0' == self.handler.getresubmission()
         assert 1 == len(self.handler.cookies)
         """ delete resubmission cookie.
         """
         self.options.update({
-                'HTTP_COOKIE_DOMAIN': None,
-                'HTTP_COOKIE_SECURE': True,
-                'HTTP_COOKIE_HTTPONLY': True
+            'HTTP_COOKIE_DOMAIN': None,
+            'HTTP_COOKIE_SECURE': True,
+            'HTTP_COOKIE_HTTPONLY': True
         })
         self.mock_request.cookies['_r'] = '100'
         self.handler.delresubmission()
         """ counter is not valid integer value.
         """
         self.options.update({
-                'HTTP_COOKIE_DOMAIN': None,
-                'HTTP_COOKIE_SECURE': True,
-                'HTTP_COOKIE_HTTPONLY': True
+            'HTTP_COOKIE_DOMAIN': None,
+            'HTTP_COOKIE_SECURE': True,
+            'HTTP_COOKIE_HTTPONLY': True
         })
         self.mock_request.ajax = False
         self.mock_request.cookies['_r'] = 'x'
         """ validate_resubmission.
         """
         self.options.update({
-                'HTTP_COOKIE_DOMAIN': None,
-                'HTTP_COOKIE_SECURE': True,
-                'HTTP_COOKIE_HTTPONLY': True
+            'HTTP_COOKIE_DOMAIN': None,
+            'HTTP_COOKIE_SECURE': True,
+            'HTTP_COOKIE_HTTPONLY': True
         })
         self.mock_request.ajax = False
         self.mock_request.cookies['_r'] = '247'
         self.mock_request.method = 'GET'
         self.mock_request.root_path = 'my_site/'
         self.mock_request.urlparts = urlparts(
-                scheme='https', netloc='python.org')
+            scheme='https', netloc='python.org')
         self.handler = handler_factory(
-                RedirectRouteHandler,
-                self.mock_request,
-                'default')
+            RedirectRouteHandler,
+            self.mock_request,
+            'default')
         assert isinstance(self.handler, RedirectRouteHandler)
 
     def test_redirect_http_get(self):
         self.mock_request.ajax = False
         self.mock_request.root_path = 'my_site/'
         self.mock_request.urlparts = urlparts(
-                scheme='https', netloc='python.org')
+            scheme='https', netloc='python.org')
 
     def test_redirect_http_get(self):
         """ get.
         self.mock_request.ajax = False
         self.mock_request.root_path = 'my_site/'
         self.mock_request.urlparts = urlparts(
-                scheme='https', netloc='python.org')
+            scheme='https', netloc='python.org')
 
     def test_redirect_http_get(self):
         """ get.

src/wheezy/web/handlers/tests/test_file.py

         self.mock_request.options = self.options
         self.route_args = {}
         self.mock_request.environ = {
-                'route_args': self.route_args
+            'route_args': self.route_args
         }
         self.mock_request.root_path = 'my_site/'
         self.handler = handler_factory(
-                FileHandler,
-                self.mock_request,
-                root=rootdir)
+            FileHandler,
+            self.mock_request,
+            root=rootdir)
 
     def test_get_out_of_root_path(self):
         """ if requested file is not within root directory
         self.route_args = {}
         self.mock_request.method = 'GET'
         self.mock_request.environ = {
-                'route_args': self.route_args
+            'route_args': self.route_args
         }
         self.mock_request.root_path = 'my_site/'
 

src/wheezy/web/handlers/tests/test_method.py

         """
         from wheezy.web.handlers.method import MethodHandler
         for method in ['GET', 'POST', 'HEAD']:
-            patcher = patch('wheezy.web.handlers.method.MethodHandler.'
-                    + method.lower())
+            patcher = patch(
+                'wheezy.web.handlers.method.MethodHandler.'
+                + method.lower())
             self.mock_request.method = method
             mock_method = patcher.start()
             mock_method.return_value = 'response'

src/wheezy/web/handlers/tests/test_template.py

         from wheezy.web.handlers.template import TemplateHandler
         from wheezy.web.handlers.method import handler_factory
         self.options = {
-                'CONTENT_TYPE': 'text/plain',
-                'ENCODING': 'UTF-8',
-                'AUTH_COOKIE': '_a'
+            'CONTENT_TYPE': 'text/plain',
+            'ENCODING': 'UTF-8',
+            'AUTH_COOKIE': '_a'
         }
         self.mock_request = Mock()
         self.mock_request.options = self.options
         self.route_args = {}
         self.mock_request.environ = {
-                'route_args': self.route_args
+            'route_args': self.route_args
         }
         self.mock_request.root_path = 'my_site/'
         self.mock_request.cookies = {}
         self.handler = handler_factory(
-                TemplateHandler,
-                self.mock_request,
-                template_name='test.html')
+            TemplateHandler,
+            self.mock_request,
+            template_name='test.html')
 
     def test_get(self):
         """ get.
 
     def setUp(self):
         self.options = {
-                'CONTENT_TYPE': 'text/plain',
-                'ENCODING': 'UTF-8',
-                'AUTH_COOKIE': '_a'
+            'CONTENT_TYPE': 'text/plain',
+            'ENCODING': 'UTF-8',
+            'AUTH_COOKIE': '_a'
         }
         self.mock_request = Mock()
         self.mock_request.options = self.options
         self.route_args = {}
         self.mock_request.environ = {
-                'route_args': self.route_args
+            'route_args': self.route_args
         }
         self.mock_request.method = 'GET'
         self.mock_request.root_path = 'my_site/'

src/wheezy/web/middleware/bootstrap.py

             options['ticket'] = Ticket()
 
         options.setdefault('ENCODING', 'UTF-8')
-        options.setdefault('CONTENT_TYPE', 'text/html; charset=' +
-                options['ENCODING'])
+        options.setdefault(
+            'CONTENT_TYPE', 'text/html; charset=' + options['ENCODING'])
         options.setdefault('AUTH_COOKIE', '_a')
         options.setdefault('AUTH_COOKIE_DOMAIN', None)
         options.setdefault('AUTH_COOKIE_PATH', '')

src/wheezy/web/middleware/errors.py

             assert path_for(route_name) is not None
     else:
         error_mapping = defaultdict(str)
-    return HTTPErrorMiddleware(
-            error_mapping=error_mapping)
+    return HTTPErrorMiddleware(error_mapping=error_mapping)

src/wheezy/web/middleware/tests/test_bootstrap.py

         from wheezy.web.middleware.bootstrap import bootstrap_defaults
         mock_path_router = Mock()
         options = {
-                'path_router': mock_path_router
+            'path_router': mock_path_router
         }
 
         assert None == bootstrap_defaults({

src/wheezy/web/middleware/tests/test_errors.py

         from wheezy.web.middleware.errors import HTTPErrorMiddleware
         mock_request = Mock()
         mock_request.environ = {
-                'route_args': {'route_name': 'http404'}
+            'route_args': {'route_name': 'http404'}
         }
         mock_following = Mock(return_value=None)
         middleware = HTTPErrorMiddleware({
-                404: 'http404'
+            404: 'http404'
         })
         response = middleware(mock_request, mock_following)
         assert 404 == response.status_code
         from wheezy.web.middleware.errors import HTTPErrorMiddleware
         mock_request = Mock()
         mock_request.environ = {
-                'route_args': {'route_name': 'http500'}
+            'route_args': {'route_name': 'http500'}
         }
         mock_following = Mock(side_effect=ValueError)
         middleware = HTTPErrorMiddleware({
-                500: 'http500'
+            500: 'http500'
         })
         response = middleware(mock_request, mock_following)
         assert 500 == response.status_code
         from wheezy.web.middleware.errors import HTTPErrorMiddleware
         mock_request = Mock()
         mock_request.environ = {
-                'route_args': {'route_name': 'http500'}
+            'route_args': {'route_name': 'http500'}
         }
         for error in [KeyboardInterrupt, SystemExit, MemoryError]:
             mock_following = Mock(side_effect=error)
             middleware = HTTPErrorMiddleware({})
-            self.assertRaises(error,
-                    lambda: middleware(mock_request, mock_following))
+            self.assertRaises(
+                error,
+                lambda: middleware(mock_request, mock_following))
 
     def test_following_response_needs_redirect(self):
         """ The following middleware returns error status
         mock_request = Mock()
         mock_path_for = Mock(return_value='not_found')
         mock_request.options = {
-                'path_for': mock_path_for
+            'path_for': mock_path_for
         }
         mock_request.root_path = 'my_site/'
         mock_request.method = 'GET'
         mock_request.ajax = False
         mock_request.environ = {
-                'route_args': {'route_name': 'welcome'}
+            'route_args': {'route_name': 'welcome'}
         }
         mock_following = Mock(return_value=None)
         middleware = HTTPErrorMiddleware({
-                404: 'http404'
+            404: 'http404'
         })
         response = middleware(mock_request, mock_following)
         assert 302 == response.status_code
         from wheezy.web.middleware.errors import http_error_middleware_factory
         mock_path_for = Mock()
         middleware = http_error_middleware_factory({
-                'path_for': mock_path_for
+            'path_for': mock_path_for
         })
         assert middleware
 
         from wheezy.web.middleware.errors import http_error_middleware_factory
         mock_path_for = Mock()
         middleware = http_error_middleware_factory({
-                'path_for': mock_path_for,
-                'http_errors': defaultdict(lambda: 'http500', {
-                        404: 'http400'
-                })
+            'path_for': mock_path_for,
+            'http_errors': defaultdict(lambda: 'http500', {
+                404: 'http400'
+            })
         })
         assert middleware

src/wheezy/web/middleware/tests/test_routing.py

         from wheezy.web.middleware.routing import PathRoutingMiddleware
         mock_request = Mock()
         mock_request.environ = {
-                'PATH_INFO': '/en/signin'
+            'PATH_INFO': '/en/signin'
         }
         mock_following = Mock(return_value='response')
         mock_path_router = Mock()
         from wheezy.web.middleware.routing import PathRoutingMiddleware
         mock_request = Mock()
         mock_request.environ = {
-                'PATH_INFO': '/en/signin'
+            'PATH_INFO': '/en/signin'
         }
         mock_path_router = Mock()
         mock_path_router.match.return_value = (None, {})
         from wheezy.web.middleware.routing import PathRoutingMiddleware
         mock_request = Mock()
         mock_request.environ = {
-                'PATH_INFO': '/en/signin'
+            'PATH_INFO': '/en/signin'
         }
         mock_path_router = Mock()
         mock_handler = Mock(return_value='response')
         """ Returns an instance of PathRoutingMiddleware.
         """
         from wheezy.web.middleware.routing \
-                import path_routing_middleware_factory
+            import path_routing_middleware_factory
         mock_path_router = Mock()
         assert path_routing_middleware_factory({
-                'path_router': mock_path_router
+            'path_router': mock_path_router
         })

src/wheezy/web/templates.py

     """
     __slots__ = ('template_lookup')
 
-    def __init__(self,
-            directories=None,
+    def __init__(
+            self, directories=None,
             module_directory='/tmp/mako_modules',
             cache_factory=None,
             **kwargs):
         from mako.lookup import TemplateLookup
         if cache_factory is None:
             self.template_lookup = TemplateLookup(
-                    directories=directories or ['content/templates'],
-                    module_directory=module_directory,
+                directories=directories or ['content/templates'],
+                module_directory=module_directory,
                 **kwargs)
         else:
             from mako.cache import register_plugin
             register_plugin('wheezy', 'wheezy.web.templates', 'MakoCacheImpl')
             self.template_lookup = TemplateLookup(
-                    directories=directories or ['content/templates'],
-                    module_directory=module_directory,
-                    cache_impl='wheezy',
-                    cache_args={'cache_factory': cache_factory},
-                    **kwargs)
+                directories=directories or ['content/templates'],
+                module_directory=module_directory,
+                cache_impl='wheezy',
+                cache_args={'cache_factory': cache_factory},
+                **kwargs)
 
     def __call__(self, template_name, kwargs):
         template = self.template_lookup.get_template(template_name)
             if value is None:
                 value = creation_function()
                 cache.add(
-                        self.prefix + key,
-                        value,
-                        int(kwargs.get('time', 0)),
-                        namespace)
+                    self.prefix + key,
+                    value,
+                    int(kwargs.get('time', 0)),
+                    namespace)
             return value
         finally:
             context.__exit__(None, None, None)
     """
     __slots__ = ('engine', 'helpers')
 
-    def __init__(self, path=None, pp=None, helpers=None,
-            encoding='UTF-8', postfix='.html', cache=None,
-            **kwargs):
+    def __init__(
+            self, path=None, pp=None, helpers=None,
+            encoding='UTF-8', postfix='.html', cache=None, **kwargs):
         import tenjin
         tenjin.set_template_encoding(encoding)
         from tenjin.helpers import capture_as, escape, captured_as, cache_as
         from wheezy.core.comp import str_type
         self.helpers = {
-                'to_str': str_type,
-                'escape': escape,
-                'capture_as': capture_as,
-                'captured_as': captured_as,
-                'cache_as': cache_as,
-                'tenjin': tenjin
+            'to_str': str_type,
+            'escape': escape,
+            'capture_as': capture_as,
+            'captured_as': captured_as,
+            'cache_as': cache_as,
+            'tenjin': tenjin
         }
         if helpers:
             self.helpers.update(helpers)
         self.engine = tenjin.Engine(
-                path=path or ['content/templates'],
-                postfix=postfix,
-                cache=cache or tenjin.MemoryCacheStorage(),
-                pp=pp,
-                **kwargs)
+            path=path or ['content/templates'],
+            postfix=postfix,
+            cache=cache or tenjin.MemoryCacheStorage(),
+            pp=pp,
+            **kwargs)
 
     def __call__(self, template_name, kwargs):
         return self.engine.render(template_name, kwargs, self.helpers)

src/wheezy/web/tests/test_templates.py

         assert MakoTemplate()
         assert not self.mock_register_plugin.called
         self.mock_template_lookup_class.assert_called_once_with(
-                directories=['content/templates'],
-                module_directory='/tmp/mako_modules',
+            directories=['content/templates'],
+            module_directory='/tmp/mako_modules',
         )
 
     def test_init_with_cache_factory(self):
         """
         from wheezy.web.templates import MakoTemplate
         assert MakoTemplate(
-                cache_factory='mock_cache_factory'
+            cache_factory='mock_cache_factory'
         )
         self.mock_template_lookup_class.assert_called_once_with(
-                directories=['content/templates'],
-                module_directory='/tmp/mako_modules',
-                cache_impl='wheezy',
-                cache_args={'cache_factory': 'mock_cache_factory'}
+            directories=['content/templates'],
+            module_directory='/tmp/mako_modules',
+            cache_impl='wheezy',
+            cache_args={'cache_factory': 'mock_cache_factory'}
         )
         self.mock_register_plugin.assert_called_once_with(
-                'wheezy', 'wheezy.web.templates', 'MakoCacheImpl')
+            'wheezy', 'wheezy.web.templates', 'MakoCacheImpl')
 
     def test_render(self):
         """ __call__.
         """
         from wheezy.web.templates import MakoTemplate
         self.mock_template_lookup_class.return_value \
-                .get_template.return_value.render.return_value = 'html'
+            .get_template.return_value.render.return_value = 'html'
         template = MakoTemplate()
         assert 'html' == template('signin.html', {'user': 'john'})
         self.mock_template_lookup_class.return_value \
-                .get_template.assert_called_once_with('signin.html')
+            .get_template.assert_called_once_with('signin.html')
         self.mock_template_lookup_class.return_value \
-                .get_template.return_value \
-                .render.assert_called_once_with(user='john')
+            .get_template.return_value \
+            .render.assert_called_once_with(user='john')
 
 
 class MakoCacheImplTestCase(unittest.TestCase):
         self.mock_cache_factory = Mock()
         mock_mako_cache = Mock()
         mock_mako_cache.template.cache_args = {
-                'cache_factory': self.mock_cache_factory
+            'cache_factory': self.mock_cache_factory
         }
         mock_mako_cache.id = 'prefix-'
         self.cache = MakoCacheImpl(mock_mako_cache)
         """ set, get and invalidate raise error.
         """
         self.assertRaises(NotImplementedError,
-                lambda: self.cache.set('key', 1))
+                          lambda: self.cache.set('key', 1))
         self.assertRaises(NotImplementedError,
-                lambda: self.cache.get('key'))
+                          lambda: self.cache.get('key'))
         self.assertRaises(NotImplementedError,
-                lambda: self.cache.invalidate('key'))
+                          lambda: self.cache.invalidate('key'))
 
     def test_get_or_create_missing_in_cache(self):
         """ Requested item is missing in cache.
         self.mock_cache_factory.return_value = mock_context
         mock_creation_function = Mock(return_value='html')
         assert 'html' == self.cache.get_or_create(
-                'key',
-                mock_creation_function,
-                namespace='namespace',
-                time='100')
+            'key',
+            mock_creation_function,
+            namespace='namespace',
+            time='100')
         mock_cache.get.assert_called_once_with(
-                'prefix-key', 'namespace')
+            'prefix-key', 'namespace')
         mock_cache.add.assert_called_once_with(
-                'prefix-key', 'html', 100, 'namespace')
+            'prefix-key', 'html', 100, 'namespace')
 
     def test_get_or_create_found_in_cache(self):
         """ Requested item found in cache.
         self.mock_cache_factory.return_value = mock_context
         mock_creation_function = Mock()
         assert 'html' == self.cache.get_or_create(
-                'key',
-                mock_creation_function,
-                namespace='namespace',
-                time='100')
+            'key',
+            mock_creation_function,
+            namespace='namespace',
+            time='100')
         mock_cache.get.assert_called_once_with(
-                'prefix-key', 'namespace')
+            'prefix-key', 'namespace')
         assert not mock_creation_function.called
 
 
         template = TenjinTemplate()
         assert ['cache_as', 'capture_as', 'captured_as',
                 'escape', 'tenjin', 'to_str'] == sorted(
-                        template.helpers.keys())
+                    template.helpers.keys())
         self.mock_encoding.assert_called_once_with('UTF-8')
         self.mock_cache.assert_called_once_with()
         self.mock_engine.assert_called_once_with(
-                path=['content/templates'],
-                postfix='.html',
-                pp=None,
-                cache=self.mock_cache.return_value
+            path=['content/templates'],
+            postfix='.html',
+            pp=None,
+            cache=self.mock_cache.return_value
         )
 
     def test_init_with_helpers(self):
         """
         from wheezy.web.templates import TenjinTemplate
         helpers = {
-                'to_str': 'to_str',
-                'escape': 'escape',
-                'capture_as': 'capture_as',
-                'captured_as': 'captured_as',
-                'cache_as': 'cache_as',
-                'tenjin': 'tenjin'
+            'to_str': 'to_str',
+            'escape': 'escape',
+            'capture_as': 'capture_as',
+            'captured_as': 'captured_as',
+            'cache_as': 'cache_as',
+            'tenjin': 'tenjin'
         }
         template = TenjinTemplate(helpers=helpers)
         assert helpers == template.helpers
         template = TenjinTemplate()
         assert 'html' == template('signin.html', {'user': 'john'})
         mock_render.assert_called_once_with('signin.html', {
-                'user': 'john'
-            }, template.helpers)
+            'user': 'john'
+        }, template.helpers)
 
 
 class Jinja2TemplateTestCase(unittest.TestCase):
         assert 'html' == template('signin.html', {'user': 'john'})
         mock_env.get_template.assert_called_once_with('signin.html')
         mock_render.assert_called_once_with({
-                'user': 'john'
-            })
+            'user': 'john'
+        })
 
 
 class WheezyTemplateTestCase(unittest.TestCase):
         template = WheezyTemplate(mock_engine)
         assert 'html' == template('signin.html', {'user': 'john'})
         mock_render.assert_called_once_with(
-                'signin.html',
-                {'user': 'john'},
-                {}, {}
+            'signin.html',
+            {'user': 'john'},
+            {}, {}
         )

src/wheezy/web/tests/test_transforms.py

         mock_handler.request = 'request'
         mock_handler_method = Mock(return_value='response')
         handler = handler_transforms(
-                transformA, transformB)(mock_handler_method)
+            transformA, transformB)(mock_handler_method)
         assert 'response-A-B' == handler(mock_handler)

src/wheezy/web/transforms.py

 
             def single_strategy(handler, *args, **kwargs):
                 return transform(
-                        handler.request,
-                        factory(handler, *args, **kwargs))
+                    handler.request,
+                    factory(handler, *args, **kwargs))
             return single_strategy
         else:
             def multi_strategy(handler, *args, **kwargs):
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.