mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 17:19:42 +00:00
Flake8 fixes for src
This commit is contained in:
parent
b911dc9c53
commit
756be12a2a
6 changed files with 34 additions and 28 deletions
|
|
@ -13,3 +13,5 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from humulus.app import create_app
|
from humulus.app import create_app
|
||||||
|
|
||||||
|
__all__ = ['create_app', ]
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ from flask import abort, current_app, g
|
||||||
from flask.cli import with_appcontext
|
from flask.cli import with_appcontext
|
||||||
from slugify import slugify
|
from slugify import slugify
|
||||||
|
|
||||||
|
|
||||||
def get_couch():
|
def get_couch():
|
||||||
"""Connect to the configured CouchDB."""
|
"""Connect to the configured CouchDB."""
|
||||||
if 'couch' not in g:
|
if 'couch' not in g:
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ def recipe_fg(recipe):
|
||||||
) / 200
|
) / 200
|
||||||
)
|
)
|
||||||
return '{:.3f}'.format(
|
return '{:.3f}'.format(
|
||||||
round(1 + (og - 1 - og_delta)*(1 - attenuation) + og_delta, 3)
|
round(1 + (og - 1 - og_delta) * (1 - attenuation) + og_delta, 3)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -123,9 +123,11 @@ def sort_hops(hops, form=False):
|
||||||
by_use[hop['use']].append(hop)
|
by_use[hop['use']].append(hop)
|
||||||
|
|
||||||
if form:
|
if form:
|
||||||
key = lambda hop: float(hop.duration.data)
|
def key(hop):
|
||||||
|
return float(hop.duration.data)
|
||||||
else:
|
else:
|
||||||
key = lambda hop: float(hop['duration'])
|
def key(hop):
|
||||||
|
return float(hop['duration'])
|
||||||
|
|
||||||
hops_sorted = sorted(by_use['FWH'], key=key, reverse=True)
|
hops_sorted = sorted(by_use['FWH'], key=key, reverse=True)
|
||||||
hops_sorted.extend(sorted(by_use['Boil'], key=key, reverse=True))
|
hops_sorted.extend(sorted(by_use['Boil'], key=key, reverse=True))
|
||||||
|
|
@ -145,7 +147,7 @@ def ferm_pct(fermentables):
|
||||||
total += float(ferm['amount'])
|
total += float(ferm['amount'])
|
||||||
# Add a pct to each ferm
|
# Add a pct to each ferm
|
||||||
for ferm in fermentables:
|
for ferm in fermentables:
|
||||||
ferm['pct'] = 100*float(ferm['amount'])/total
|
ferm['pct'] = 100 * float(ferm['amount']) / total
|
||||||
return fermentables
|
return fermentables
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ bp = Blueprint('recipes', __name__, url_prefix='/recipes')
|
||||||
class FermentableForm(Form):
|
class FermentableForm(Form):
|
||||||
"""Form for fermentables.
|
"""Form for fermentables.
|
||||||
|
|
||||||
CSRF is disabled for this form.yeast.form (using `Form as parent class) because it
|
CSRF is disabled for this form.yeast.form (using `Form as parent class)
|
||||||
is never used by itself.
|
because it is never used by itself.
|
||||||
"""
|
"""
|
||||||
name = StringField('Name', validators=[DataRequired()])
|
name = StringField('Name', validators=[DataRequired()])
|
||||||
type = SelectField('Type', validators=[DataRequired()],
|
type = SelectField('Type', validators=[DataRequired()],
|
||||||
|
|
@ -67,8 +67,8 @@ class FermentableForm(Form):
|
||||||
class HopForm(Form):
|
class HopForm(Form):
|
||||||
"""Form for hops.
|
"""Form for hops.
|
||||||
|
|
||||||
CSRF is disabled for this form.yeast.form (using `Form as parent class) because it
|
CSRF is disabled for this form.yeast.form (using `Form as parent class)
|
||||||
is never used by itself.
|
because it is never used by itself.
|
||||||
"""
|
"""
|
||||||
name = StringField('Name', validators=[DataRequired()])
|
name = StringField('Name', validators=[DataRequired()])
|
||||||
use = SelectField('Usage', validators=[DataRequired()],
|
use = SelectField('Usage', validators=[DataRequired()],
|
||||||
|
|
@ -96,8 +96,8 @@ class HopForm(Form):
|
||||||
class YeastForm(Form):
|
class YeastForm(Form):
|
||||||
"""Form for yeast.
|
"""Form for yeast.
|
||||||
|
|
||||||
CSRF is disabled for this form.yeast.form (using `Form as parent class) because it
|
CSRF is disabled for this form.yeast.form (using `Form as parent class)
|
||||||
is never used by itself.
|
because it is never used by itself.
|
||||||
"""
|
"""
|
||||||
name = StringField('Name', validators=[Optional()])
|
name = StringField('Name', validators=[Optional()])
|
||||||
type = SelectField('Type', default='',
|
type = SelectField('Type', default='',
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ def sub_to_doc(sub):
|
||||||
doc['ibu']['low'] = (sub.find('./stats/ibu/low').text
|
doc['ibu']['low'] = (sub.find('./stats/ibu/low').text
|
||||||
if sub.find('./stats/ibu/low') is not None else '0')
|
if sub.find('./stats/ibu/low') is not None else '0')
|
||||||
doc['ibu']['high'] = (sub.find('./stats/ibu/high').text
|
doc['ibu']['high'] = (sub.find('./stats/ibu/high').text
|
||||||
if sub.find('./stats/ibu/high') is not None else '100')
|
if sub.find('./stats/ibu/high') is not None
|
||||||
|
else '100')
|
||||||
doc['og']['low'] = (sub.find('./stats/og/low').text
|
doc['og']['low'] = (sub.find('./stats/og/low').text
|
||||||
if sub.find('./stats/og/low') is not None else '1.0')
|
if sub.find('./stats/og/low') is not None else '1.0')
|
||||||
doc['og']['high'] = (sub.find('./stats/og/high').text
|
doc['og']['high'] = (sub.find('./stats/og/high').text
|
||||||
|
|
@ -77,11 +78,13 @@ def sub_to_doc(sub):
|
||||||
doc['srm']['low'] = (sub.find('./stats/srm/low').text
|
doc['srm']['low'] = (sub.find('./stats/srm/low').text
|
||||||
if sub.find('./stats/srm/low') is not None else '0')
|
if sub.find('./stats/srm/low') is not None else '0')
|
||||||
doc['srm']['high'] = (sub.find('./stats/srm/high').text
|
doc['srm']['high'] = (sub.find('./stats/srm/high').text
|
||||||
if sub.find('./stats/srm/high') is not None else '100')
|
if sub.find('./stats/srm/high') is not None
|
||||||
|
else '100')
|
||||||
doc['abv']['low'] = (sub.find('./stats/abv/low').text
|
doc['abv']['low'] = (sub.find('./stats/abv/low').text
|
||||||
if sub.find('./stats/abv/low') is not None else '0')
|
if sub.find('./stats/abv/low') is not None else '0')
|
||||||
doc['abv']['high'] = (sub.find('./stats/abv/high').text
|
doc['abv']['high'] = (sub.find('./stats/abv/high').text
|
||||||
if sub.find('./stats/abv/high') is not None else '100')
|
if sub.find('./stats/abv/high') is not None
|
||||||
|
else '100')
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -153,11 +156,11 @@ def index():
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'styles/index.html',
|
'styles/index.html',
|
||||||
rows=rows[(page-1)*limit:page*limit],
|
rows=rows[(page - 1) * limit:page * limit],
|
||||||
descending=descending,
|
descending=descending,
|
||||||
sort_by=sort_by,
|
sort_by=sort_by,
|
||||||
page=page,
|
page=page,
|
||||||
num_pages=math.ceil(len(rows)/limit),
|
num_pages=math.ceil(len(rows) / limit),
|
||||||
limit=limit
|
limit=limit
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue