mirror of
https://github.com/wger-project/wger.git
synced 2026-02-18 00:17:51 +01:00
Fix pep8 errors
Also, move the settings for the pep8 checks from the command line to a configuration file, which is a better solution anyway.
This commit is contained in:
@@ -39,7 +39,7 @@ script:
|
||||
- coverage run --source='.' ./manage.py test
|
||||
|
||||
# Formatting
|
||||
- pep8 --max-line-length=100 --exclude="urls.py,*migrations*" wger
|
||||
- pep8 wger
|
||||
|
||||
# Code coverage
|
||||
- coverage report
|
||||
|
||||
@@ -75,7 +75,7 @@ Contributing
|
||||
* **Code according to PEP8**: check that the code is structured as per pep8 but
|
||||
with a maximum line length of 100. This can be checked automatically with the
|
||||
pep8 tool (pip install pep8) from the command line (travis will do this as part
|
||||
of the tests): ``pep8 --max-line-length=100--exclude="urls.py,*migrations*" wger``
|
||||
of the tests): ``pep8 wger``
|
||||
|
||||
* **code for python3**: while the application should remain compatible with
|
||||
python2, use django's suggestion to mantain sanity: code for py3 and treat
|
||||
|
||||
4
setup.cfg
Normal file
4
setup.cfg
Normal file
@@ -0,0 +1,4 @@
|
||||
[pep8]
|
||||
exclude = urls.py,*migrations*
|
||||
max-line-length = 100
|
||||
ignore = W503
|
||||
@@ -116,7 +116,7 @@ def create_demo_entries(user):
|
||||
exercise = Exercise.objects.get(pk=25)
|
||||
else:
|
||||
exercise = Exercise.objects.get(pk=84)
|
||||
day_set = Set(exerciseday=day, sets=4, order=2)
|
||||
day_set = Set(exerciseday=day, sets=4, order=2)
|
||||
day_set.save()
|
||||
day_set.exercises.add(exercise)
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ def pagination(paginator, page):
|
||||
page_range = paginator.page_range
|
||||
|
||||
# Set the template variables
|
||||
return {'page': page,
|
||||
return {'page': page,
|
||||
'page_range': page_range}
|
||||
|
||||
|
||||
|
||||
@@ -207,8 +207,8 @@ class PreferencesCalculationsTestCase(WorkoutManagerTestCase):
|
||||
user = User.objects.get(pk=2)
|
||||
bmi = user.userprofile.calculate_bmi()
|
||||
self.assertEqual(bmi,
|
||||
user.userprofile.weight.quantize(TWOPLACES)
|
||||
/ decimal.Decimal(1.80 * 1.80).quantize(TWOPLACES))
|
||||
user.userprofile.weight.quantize(TWOPLACES) /
|
||||
decimal.Decimal(1.80 * 1.80).quantize(TWOPLACES))
|
||||
|
||||
def test_basal_metabolic_rate(self):
|
||||
'''
|
||||
|
||||
@@ -46,7 +46,7 @@ class Command(BaseCommand):
|
||||
dest='remote_url',
|
||||
default='https://wger.de',
|
||||
help='Remote URL to fetch the exercises from (default: https://wger.de)'),
|
||||
)
|
||||
)
|
||||
|
||||
help = ('Download exercise images from wger.de and update the local database\n'
|
||||
'\n'
|
||||
|
||||
@@ -83,15 +83,15 @@ def workout_log(request, id, uidb64=None, token=None):
|
||||
{'description': workout},
|
||||
styleSheet["HeaderBold"])
|
||||
elements.append(p)
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
|
||||
# Iterate through the Workout and render the training days
|
||||
for day in workout.canonical_representation['day_list']:
|
||||
elements.append(render_workout_day(day, nr_of_weeks=7))
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
|
||||
# Footer, date and info
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
elements.append(render_footer(request.build_absolute_uri(workout.get_absolute_url())))
|
||||
|
||||
# write the document and send the response to the browser
|
||||
@@ -277,13 +277,13 @@ def workout_view(request, id, uidb64=None, token=None):
|
||||
elements.append(p)
|
||||
|
||||
# Filler
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
|
||||
# Append the table
|
||||
elements.append(t)
|
||||
|
||||
# Footer, date and info
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
created = datetime.date.today().strftime("%d.%m.%Y")
|
||||
p = Paragraph('''<para align="left">
|
||||
%(date)s -
|
||||
|
||||
@@ -124,21 +124,21 @@ def export_pdf(request, pk, uidb64=None, token=None):
|
||||
# Set the title
|
||||
p = Paragraph(u'<para align="center">{0}</para>'.format(schedule), styleSheet["HeaderBold"])
|
||||
elements.append(p)
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
|
||||
# Iterate through the Workout and render the training days
|
||||
for step in schedule.schedulestep_set.all():
|
||||
p = Paragraph(u'<para>{0} {1}</para>'.format(step.duration, _('Weeks')),
|
||||
styleSheet["HeaderBold"])
|
||||
elements.append(p)
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
|
||||
for day in step.workout.canonical_representation['day_list']:
|
||||
elements.append(render_workout_day(day, nr_of_weeks=7))
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
|
||||
# Footer, date and info
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
url = reverse('manager:schedule:view', kwargs={'pk': schedule.id})
|
||||
elements.append(render_footer(request.build_absolute_uri(url)))
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ def chart_data(request):
|
||||
|
||||
{'key': 'obese_class_3', 'height': 150, 'weight': 190},
|
||||
{'key': 'obese_class_3', 'height': 200, 'weight': 190}
|
||||
])
|
||||
])
|
||||
|
||||
# Return the results to the client
|
||||
return HttpResponse(data, 'application/json')
|
||||
|
||||
@@ -300,7 +300,7 @@ def export_pdf(request, id, uidb64=None, token=None):
|
||||
elements.append(p)
|
||||
|
||||
# Filler
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
|
||||
# append the table to the document
|
||||
elements.append(t)
|
||||
@@ -356,7 +356,7 @@ def export_pdf(request, id, uidb64=None, token=None):
|
||||
elements.append(t)
|
||||
|
||||
# Footer, date and info
|
||||
elements.append(Spacer(10*cm, 0.5*cm))
|
||||
elements.append(Spacer(10 * cm, 0.5 * cm))
|
||||
created = datetime.date.today().strftime("%d.%m.%Y")
|
||||
url = reverse('nutrition:plan:view', kwargs={'id': plan.id})
|
||||
p = Paragraph('''<para align="left">
|
||||
|
||||
@@ -267,7 +267,7 @@ THUMBNAIL_ALIASES = {
|
||||
|
||||
'large': {'size': (800, 800), 'quality': 90},
|
||||
'large_cropped': {'size': (800, 800), 'crop': 'smart', 'quality': 90},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ def processor(request):
|
||||
'request_full_path': full_path,
|
||||
|
||||
# The current full path with host
|
||||
'request_absolute_path': request.build_absolute_uri(),
|
||||
'image_absolute_path': request.build_absolute_uri(static_path),
|
||||
'request_absolute_path': request.build_absolute_uri(),
|
||||
'image_absolute_path': request.build_absolute_uri(static_path),
|
||||
|
||||
|
||||
# Translation links
|
||||
|
||||
@@ -47,4 +47,4 @@ class WeightForm(ModelForm):
|
||||
exclude = []
|
||||
widgets = {
|
||||
'user': widgets.HiddenInput(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user