From 6d68f6638fcc9d7b34f09d266b863b031151d492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sat, 9 Jul 2016 22:59:25 +0100 Subject: [PATCH] PEP8: few more changes Taken MR comments into account: * `and` is considered a binary operator, thus put at the beginning of the line when splitting a line, * same for `+`, * same for `.` (different reasons). --- bda/algorithm.py | 4 ++-- bda/forms.py | 4 ++-- bda/views.py | 8 ++++---- gestioncof/autocomplete.py | 4 ++-- gestioncof/forms.py | 12 ++++++------ gestioncof/petits_cours_views.py | 18 +++++++++--------- gestioncof/views.py | 8 ++++---- tirage_bda.py | 4 ++-- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/bda/algorithm.py b/bda/algorithm.py index a948d288..005e714f 100644 --- a/bda/algorithm.py +++ b/bda/algorithm.py @@ -87,8 +87,8 @@ class Algorithm(object): if len(winners) + 1 < show.slots: self.appendResult(winners, member, show) self.appendResult(winners, member, show) - elif not self.choices[member][show].autoquit and\ - len(winners) < show.slots: + elif not self.choices[member][show].autoquit \ + and len(winners) < show.slots: self.appendResult(winners, member, show) self.appendResult(losers, member, show) else: diff --git a/bda/forms.py b/bda/forms.py index 1b93c6ef..213ec17b 100644 --- a/bda/forms.py +++ b/bda/forms.py @@ -43,5 +43,5 @@ class ResellForm(forms.Form): def __init__(self, participant, *args, **kwargs): super(ResellForm, self).__init__(*args, **kwargs) - self.fields['spectacle'].queryset = participant.attributions.all().\ - distinct() + self.fields['spectacle'].queryset = participant.attributions.all() \ + .distinct() diff --git a/bda/views.py b/bda/views.py index c09b5baa..d67044cf 100644 --- a/bda/views.py +++ b/bda/views.py @@ -119,8 +119,8 @@ def places_ics(request, tirage_id): places_dict[place.spectacle].double = True else: place.double = False - place.spectacle.dtend = place.spectacle.date + \ - timedelta(seconds=7200) + place.spectacle.dtend = place.spectacle.date \ + + timedelta(seconds=7200) places_dict[place.spectacle] = place spectacles.append(place.spectacle) filtered_places.append(place) @@ -201,8 +201,8 @@ def do_tirage(request, tirage_id): data = {} shows = tirage_elt.spectacle_set.select_related().all() members = tirage_elt.participant_set.all() - choices = ChoixSpectacle.objects.filter(spectacle__tirage=tirage_elt).\ - order_by('participant', 'priority').select_related().all() + choices = ChoixSpectacle.objects.filter(spectacle__tirage=tirage_elt) \ + .order_by('participant', 'priority').select_related().all() algo = Algorithm(shows, members, choices) results = algo(form.cleaned_data["token"]) total_slots = 0 diff --git a/gestioncof/autocomplete.py b/gestioncof/autocomplete.py index 4b222f06..21b5c3bc 100644 --- a/gestioncof/autocomplete.py +++ b/gestioncof/autocomplete.py @@ -39,8 +39,8 @@ def autocomplete(request): flat='True')) \ + list(queries['users'].values_list('profile__login_clipper', flat='True')) - queries['clippers'] = queries['clippers'].\ - exclude(username__in=usernames).distinct() + queries['clippers'] = queries['clippers'] \ + .exclude(username__in=usernames).distinct() # add clippers data.update(queries) diff --git a/gestioncof/forms.py b/gestioncof/forms.py index 8cfd6b9f..ed749814 100644 --- a/gestioncof/forms.py +++ b/gestioncof/forms.py @@ -102,8 +102,8 @@ class SurveyStatusFilterForm(forms.Form): for question in survey.questions.all(): for answer in question.answers.all(): name = "question_%d_answer_%d" % (question.id, answer.id) - if self.is_bound and\ - self.data.get(self.add_prefix(name), None): + if self.is_bound \ + and self.data.get(self.add_prefix(name), None): initial = self.data.get(self.add_prefix(name), None) else: initial = "none" @@ -132,8 +132,8 @@ class EventStatusFilterForm(forms.Form): for option in event.options.all(): for choice in option.choices.all(): name = "option_%d_choice_%d" % (option.id, choice.id) - if self.is_bound and\ - self.data.get(self.add_prefix(name), None): + if self.is_bound \ + and self.data.get(self.add_prefix(name), None): initial = self.data.get(self.add_prefix(name), None) else: initial = "none" @@ -309,8 +309,8 @@ class AdminEventForm(forms.Form): initial = commentfield.default if registration is not None: try: - initial = registration.comments.\ - get(commentfield=commentfield).content + initial = registration.comments \ + .get(commentfield=commentfield).content except EventCommentValue.DoesNotExist: pass widget = forms.Textarea if commentfield.fieldtype == "text" \ diff --git a/gestioncof/petits_cours_views.py b/gestioncof/petits_cours_views.py index a4353b09..89bfe36e 100644 --- a/gestioncof/petits_cours_views.py +++ b/gestioncof/petits_cours_views.py @@ -56,12 +56,12 @@ def details(request, demande_id): def _get_attrib_counter(user, matiere): - counter, created = PetitCoursAttributionCounter.\ - objects.get_or_create(user=user, matiere=matiere) + counter, created = PetitCoursAttributionCounter \ + .objects.get_or_create(user=user, matiere=matiere) if created: - mincount = PetitCoursAttributionCounter.objects.\ - filter(matiere=matiere).exclude(user=user).all().\ - aggregate(Min('count')) + mincount = PetitCoursAttributionCounter.objects \ + .filter(matiere=matiere).exclude(user=user).all() \ + .aggregate(Min('count')) counter.count = mincount['count__min'] counter.save() return counter @@ -76,8 +76,8 @@ def _get_demande_candidates(demande, redo=False): if demande.agrege_requis: candidates = candidates.filter(agrege=True) if redo: - attributions = PetitCoursAttribution.objects.\ - filter(demande=demande, matiere=matiere).all() + attributions = PetitCoursAttribution.objects \ + .filter(demande=demande, matiere=matiere).all() for attrib in attributions: candidates = candidates.exclude(user=attrib.user) candidates = candidates.order_by('?').select_related().all() @@ -352,8 +352,8 @@ def inscription(request): profile.save() lock_table(PetitCoursAttributionCounter, PetitCoursAbility, User, PetitCoursSubject) - abilities = PetitCoursAbility.objects.\ - filter(user=request.user).all() + abilities = PetitCoursAbility.objects \ + .filter(user=request.user).all() for ability in abilities: counter = _get_attrib_counter(ability.user, ability.matiere) unlock_tables() diff --git a/gestioncof/views.py b/gestioncof/views.py index fb9fbcb8..11d15d53 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -427,8 +427,8 @@ def registration(request): if form.cleaned_data['status'] == 'no': continue all_choices = get_event_form_choices(form.event, form) - if user_form.is_valid() and profile_form.is_valid() and \ - not any([not form.is_valid() for form in event_forms]): + if user_form.is_valid() and profile_form.is_valid() \ + and not any([not form.is_valid() for form in event_forms]): member = user_form.save() (profile, _) = CofProfile.objects.get_or_create(user=member) was_cof = profile.is_cof @@ -579,8 +579,8 @@ def export_mega_participants(request): @buro_required def export_mega(request): event = Event.objects.filter(title="Mega 15") - qs = EventRegistration.objects.filter(event=event).\ - order_by("user__username") + qs = EventRegistration.objects.filter(event=event) \ + .order_by("user__username") return csv_export_mega('all_mega_2015.csv', qs) diff --git a/tirage_bda.py b/tirage_bda.py index a4e46380..8d01d6c6 100644 --- a/tirage_bda.py +++ b/tirage_bda.py @@ -15,8 +15,8 @@ if __name__ == "__main__": start = time.time() shows = Spectacle.objects.all() members = Participant.objects.all() - choices = ChoixSpectacle.objects.order_by('participant', 'priority').\ - select_related().all() + choices = ChoixSpectacle.objects.order_by('participant', 'priority') \ + .select_related().all() available_slots = Spectacle.objects.aggregate(Sum('slots'))['slots__sum'] cursor = connection.cursor() cursor.execute(