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).
This commit is contained in:
Théophile Bastian 2016-07-09 22:59:25 +01:00
parent 88bccc0e60
commit 6d68f6638f
8 changed files with 31 additions and 31 deletions

View file

@ -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:

View file

@ -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()

View file

@ -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

View file

@ -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)

View file

@ -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" \

View file

@ -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()

View file

@ -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)

View file

@ -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(