From 5b16eeb8f4d00179b55e020fbd41ff6732c7132b Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sun, 8 Feb 2015 18:45:13 +0100 Subject: [PATCH] PEP8 compliancy --- src/pretix/settings.py | 4 ++-- src/pretix/wsgi.py | 2 +- src/pretixbase/types.py | 3 ++- src/pretixcontrol/views/forms.py | 24 +++++++++++++----------- src/pretixcontrol/views/item.py | 24 +++++++++++++----------- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/pretix/settings.py b/src/pretix/settings.py index 376d45cd1..dc14ee359 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -105,7 +105,7 @@ LOCALE_PATHS = ( 'locale', ) -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _ # NOQA LANGUAGES = ( ('de', _('German')), ('en', _('English')), @@ -154,6 +154,6 @@ DEFAULT_CURRENCY = 'EUR' INTERNAL_IPS = ('127.0.0.1', '::1') try: - from local_settings import * + from local_settings import * # NOQA except ImportError: pass diff --git a/src/pretix/wsgi.py b/src/pretix/wsgi.py index eab8cd925..2bd1d7ea4 100644 --- a/src/pretix/wsgi.py +++ b/src/pretix/wsgi.py @@ -10,5 +10,5 @@ https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pretix.settings") -from django.core.wsgi import get_wsgi_application +from django.core.wsgi import get_wsgi_application # NOQA application = get_wsgi_application() diff --git a/src/pretixbase/types.py b/src/pretixbase/types.py index 6b229831c..c52f67dac 100644 --- a/src/pretixbase/types.py +++ b/src/pretixbase/types.py @@ -34,7 +34,8 @@ class VariationDict(dict): the PropertyValue id's, sorted by the Property id's and is therefore unique among one item. """ - order_key = lambda i: i[0] + def order_key(i): + i[0] return ",".join(( str(v[1].pk) for v in sorted(self.relevant_items(), key=order_key) )) diff --git a/src/pretixcontrol/views/forms.py b/src/pretixcontrol/views/forms.py index 578a6b06c..4d3809955 100644 --- a/src/pretixcontrol/views/forms.py +++ b/src/pretixcontrol/views/forms.py @@ -166,18 +166,20 @@ class VariationsFieldRenderer(forms.widgets.CheckboxFieldRenderer): prop2 = properties[1] prop2v = list(prop2.values.current.all()) - # Given an iterable of PropertyValue objects, this will return a - # list of their primary keys, ordered by the primary keys of the - # properties they belong to EXCEPT the value for the property prop2. - # We'll see later why we need this. - selector = lambda values: [ - v.identity for v in sorted(values, key=lambda v: v.prop.identity) - if v.prop.identity != prop2.identity - ] + def selector(values): + # Given an iterable of PropertyValue objects, this will return a + # list of their primary keys, ordered by the primary keys of the + # properties they belong to EXCEPT the value for the property prop2. + # We'll see later why we need this. + return [ + v.identity for v in sorted(values, key=lambda v: v.prop.identity) + if v.prop.identity != prop2.identity + ] - # Given a list of variations, this will sort them by their position - # on the x-axis - sort = lambda v: v[prop2.identity].identity + def sort(v): + # Given a list of variations, this will sort them by their position + # on the x-axis + return v[prop2.identity].identity # We now iterate over the cartesian product of all the other # properties which are NOT on the axes of the grid because we diff --git a/src/pretixcontrol/views/item.py b/src/pretixcontrol/views/item.py index 77326a6f4..bca14f9ba 100644 --- a/src/pretixcontrol/views/item.py +++ b/src/pretixcontrol/views/item.py @@ -752,18 +752,20 @@ class ItemVariations(ItemDetailMixin, EventPermissionRequiredMixin, TemplateView # prop2 is the property on all the grid's x-axes prop2 = self.properties[1] - # Given an iterable of PropertyValue objects, this will return a - # list of their primary keys, ordered by the primary keys of the - # properties they belong to EXCEPT the value for the property prop2. - # We'll see later why we need this. - selector = lambda values: [ - v.identity for v in sorted(values, key=lambda v: v.prop.identity) - if v.prop.identity != prop2.identity - ] + def selector(values): + # Given an iterable of PropertyValue objects, this will return a + # list of their primary keys, ordered by the primary keys of the + # properties they belong to EXCEPT the value for the property prop2. + # We'll see later why we need this. + return [ + v.identity for v in sorted(values, key=lambda v: v.prop.identity) + if v.prop.identity != prop2.identity + ] - # Given a list of variations, this will sort them by their position - # on the x-axis - sort = lambda v: v[prop2.identity].identity + def sort(v): + # Given a list of variations, this will sort them by their position + # on the x-axis + return v[prop2.identity].identity # We now iterate over the cartesian product of all the other # properties which are NOT on the axes of the grid because we