| Conditions | 3 |
| Total Lines | 64 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | #!/usr/bin/env python |
||
| 120 | def init_app(self, app): |
||
| 121 | MATERIAL_VERSION = '0.96.1' |
||
| 122 | JQUERY_VERSION = '1.11.3' |
||
| 123 | HTML5SHIV_VERSION = '3.7.2' |
||
| 124 | RESPONDJS_VERSION = '1.4.2' |
||
| 125 | |||
| 126 | app.config.setdefault('MATERIAL_USE_MINIFIED', True) |
||
| 127 | app.config.setdefault('MATERIAL_CDN_FORCE_SSL', False) |
||
| 128 | |||
| 129 | app.config.setdefault('MATERIAL_QUERYSTRING_REVVING', True) |
||
| 130 | app.config.setdefault('MATERIAL_SERVE_LOCAL', False) |
||
| 131 | |||
| 132 | app.config.setdefault('MATERIAL_LOCAL_SUBDOMAIN', None) |
||
| 133 | |||
| 134 | blueprint = Blueprint( |
||
| 135 | 'material', |
||
| 136 | __name__, |
||
| 137 | template_folder='templates', |
||
| 138 | static_folder='static', |
||
| 139 | static_url_path=app.static_url_path + '/material', |
||
| 140 | subdomain=app.config['MATERIAL_LOCAL_SUBDOMAIN']) |
||
| 141 | |||
| 142 | app.register_blueprint(blueprint) |
||
| 143 | |||
| 144 | app.jinja_env.globals['material_is_hidden_field'] =\ |
||
| 145 | is_hidden_field_filter |
||
| 146 | app.jinja_env.globals['material_find_resource'] =\ |
||
| 147 | material_find_resource |
||
| 148 | |||
| 149 | if not hasattr(app, 'extensions'): |
||
| 150 | app.extensions = {} |
||
| 151 | |||
| 152 | local = StaticCDN('material.static', rev=True) |
||
| 153 | static = StaticCDN() |
||
| 154 | |||
| 155 | def lwrap(cdn, primary=static): |
||
| 156 | return ConditionalCDN('MATERIAL_SERVE_LOCAL', primary, cdn) |
||
| 157 | |||
| 158 | material = lwrap( |
||
| 159 | WebCDN('//cdnjs.cloudflare.com/ajax/libs/materialize/%s/' |
||
| 160 | % MATERIAL_VERSION), |
||
| 161 | local) |
||
| 162 | |||
| 163 | jquery = lwrap( |
||
| 164 | WebCDN('//cdnjs.cloudflare.com/ajax/libs/jquery/%s/' |
||
| 165 | % JQUERY_VERSION), |
||
| 166 | local) |
||
| 167 | |||
| 168 | html5shiv = lwrap( |
||
| 169 | WebCDN('//cdnjs.cloudflare.com/ajax/libs/html5shiv/%s/' |
||
| 170 | % HTML5SHIV_VERSION)) |
||
| 171 | |||
| 172 | respondjs = lwrap( |
||
| 173 | WebCDN('//cdnjs.cloudflare.com/ajax/libs/respond.js/%s/' |
||
| 174 | % RESPONDJS_VERSION)) |
||
| 175 | |||
| 176 | app.extensions['material'] = { |
||
| 177 | 'cdns': { |
||
| 178 | 'local': local, |
||
| 179 | 'static': static, |
||
| 180 | 'material': material, |
||
| 181 | 'jquery': jquery, |
||
| 182 | 'html5shiv': html5shiv, |
||
| 183 | 'respond.js': respondjs, |
||
| 184 | }, |
||
| 186 |