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: if len(winners) + 1 < show.slots:
self.appendResult(winners, member, show) self.appendResult(winners, member, show)
self.appendResult(winners, member, show) self.appendResult(winners, member, show)
elif not self.choices[member][show].autoquit and\ elif not self.choices[member][show].autoquit \
len(winners) < show.slots: and len(winners) < show.slots:
self.appendResult(winners, member, show) self.appendResult(winners, member, show)
self.appendResult(losers, member, show) self.appendResult(losers, member, show)
else: else:

View file

@ -43,5 +43,5 @@ class ResellForm(forms.Form):
def __init__(self, participant, *args, **kwargs): def __init__(self, participant, *args, **kwargs):
super(ResellForm, self).__init__(*args, **kwargs) super(ResellForm, self).__init__(*args, **kwargs)
self.fields['spectacle'].queryset = participant.attributions.all().\ self.fields['spectacle'].queryset = participant.attributions.all() \
distinct() .distinct()

View file

@ -119,8 +119,8 @@ def places_ics(request, tirage_id):
places_dict[place.spectacle].double = True places_dict[place.spectacle].double = True
else: else:
place.double = False place.double = False
place.spectacle.dtend = place.spectacle.date + \ place.spectacle.dtend = place.spectacle.date \
timedelta(seconds=7200) + timedelta(seconds=7200)
places_dict[place.spectacle] = place places_dict[place.spectacle] = place
spectacles.append(place.spectacle) spectacles.append(place.spectacle)
filtered_places.append(place) filtered_places.append(place)
@ -201,8 +201,8 @@ def do_tirage(request, tirage_id):
data = {} data = {}
shows = tirage_elt.spectacle_set.select_related().all() shows = tirage_elt.spectacle_set.select_related().all()
members = tirage_elt.participant_set.all() members = tirage_elt.participant_set.all()
choices = ChoixSpectacle.objects.filter(spectacle__tirage=tirage_elt).\ choices = ChoixSpectacle.objects.filter(spectacle__tirage=tirage_elt) \
order_by('participant', 'priority').select_related().all() .order_by('participant', 'priority').select_related().all()
algo = Algorithm(shows, members, choices) algo = Algorithm(shows, members, choices)
results = algo(form.cleaned_data["token"]) results = algo(form.cleaned_data["token"])
total_slots = 0 total_slots = 0

View file

@ -39,8 +39,8 @@ def autocomplete(request):
flat='True')) \ flat='True')) \
+ list(queries['users'].values_list('profile__login_clipper', + list(queries['users'].values_list('profile__login_clipper',
flat='True')) flat='True'))
queries['clippers'] = queries['clippers'].\ queries['clippers'] = queries['clippers'] \
exclude(username__in=usernames).distinct() .exclude(username__in=usernames).distinct()
# add clippers # add clippers
data.update(queries) data.update(queries)

View file

@ -102,8 +102,8 @@ class SurveyStatusFilterForm(forms.Form):
for question in survey.questions.all(): for question in survey.questions.all():
for answer in question.answers.all(): for answer in question.answers.all():
name = "question_%d_answer_%d" % (question.id, answer.id) name = "question_%d_answer_%d" % (question.id, answer.id)
if self.is_bound and\ if self.is_bound \
self.data.get(self.add_prefix(name), None): and self.data.get(self.add_prefix(name), None):
initial = self.data.get(self.add_prefix(name), None) initial = self.data.get(self.add_prefix(name), None)
else: else:
initial = "none" initial = "none"
@ -132,8 +132,8 @@ class EventStatusFilterForm(forms.Form):
for option in event.options.all(): for option in event.options.all():
for choice in option.choices.all(): for choice in option.choices.all():
name = "option_%d_choice_%d" % (option.id, choice.id) name = "option_%d_choice_%d" % (option.id, choice.id)
if self.is_bound and\ if self.is_bound \
self.data.get(self.add_prefix(name), None): and self.data.get(self.add_prefix(name), None):
initial = self.data.get(self.add_prefix(name), None) initial = self.data.get(self.add_prefix(name), None)
else: else:
initial = "none" initial = "none"
@ -309,8 +309,8 @@ class AdminEventForm(forms.Form):
initial = commentfield.default initial = commentfield.default
if registration is not None: if registration is not None:
try: try:
initial = registration.comments.\ initial = registration.comments \
get(commentfield=commentfield).content .get(commentfield=commentfield).content
except EventCommentValue.DoesNotExist: except EventCommentValue.DoesNotExist:
pass pass
widget = forms.Textarea if commentfield.fieldtype == "text" \ widget = forms.Textarea if commentfield.fieldtype == "text" \

View file

@ -56,12 +56,12 @@ def details(request, demande_id):
def _get_attrib_counter(user, matiere): def _get_attrib_counter(user, matiere):
counter, created = PetitCoursAttributionCounter.\ counter, created = PetitCoursAttributionCounter \
objects.get_or_create(user=user, matiere=matiere) .objects.get_or_create(user=user, matiere=matiere)
if created: if created:
mincount = PetitCoursAttributionCounter.objects.\ mincount = PetitCoursAttributionCounter.objects \
filter(matiere=matiere).exclude(user=user).all().\ .filter(matiere=matiere).exclude(user=user).all() \
aggregate(Min('count')) .aggregate(Min('count'))
counter.count = mincount['count__min'] counter.count = mincount['count__min']
counter.save() counter.save()
return counter return counter
@ -76,8 +76,8 @@ def _get_demande_candidates(demande, redo=False):
if demande.agrege_requis: if demande.agrege_requis:
candidates = candidates.filter(agrege=True) candidates = candidates.filter(agrege=True)
if redo: if redo:
attributions = PetitCoursAttribution.objects.\ attributions = PetitCoursAttribution.objects \
filter(demande=demande, matiere=matiere).all() .filter(demande=demande, matiere=matiere).all()
for attrib in attributions: for attrib in attributions:
candidates = candidates.exclude(user=attrib.user) candidates = candidates.exclude(user=attrib.user)
candidates = candidates.order_by('?').select_related().all() candidates = candidates.order_by('?').select_related().all()
@ -352,8 +352,8 @@ def inscription(request):
profile.save() profile.save()
lock_table(PetitCoursAttributionCounter, PetitCoursAbility, User, lock_table(PetitCoursAttributionCounter, PetitCoursAbility, User,
PetitCoursSubject) PetitCoursSubject)
abilities = PetitCoursAbility.objects.\ abilities = PetitCoursAbility.objects \
filter(user=request.user).all() .filter(user=request.user).all()
for ability in abilities: for ability in abilities:
counter = _get_attrib_counter(ability.user, ability.matiere) counter = _get_attrib_counter(ability.user, ability.matiere)
unlock_tables() unlock_tables()

View file

@ -427,8 +427,8 @@ def registration(request):
if form.cleaned_data['status'] == 'no': if form.cleaned_data['status'] == 'no':
continue continue
all_choices = get_event_form_choices(form.event, form) all_choices = get_event_form_choices(form.event, form)
if user_form.is_valid() and profile_form.is_valid() and \ if user_form.is_valid() and profile_form.is_valid() \
not any([not form.is_valid() for form in event_forms]): and not any([not form.is_valid() for form in event_forms]):
member = user_form.save() member = user_form.save()
(profile, _) = CofProfile.objects.get_or_create(user=member) (profile, _) = CofProfile.objects.get_or_create(user=member)
was_cof = profile.is_cof was_cof = profile.is_cof
@ -579,8 +579,8 @@ def export_mega_participants(request):
@buro_required @buro_required
def export_mega(request): def export_mega(request):
event = Event.objects.filter(title="Mega 15") event = Event.objects.filter(title="Mega 15")
qs = EventRegistration.objects.filter(event=event).\ qs = EventRegistration.objects.filter(event=event) \
order_by("user__username") .order_by("user__username")
return csv_export_mega('all_mega_2015.csv', qs) return csv_export_mega('all_mega_2015.csv', qs)

View file

@ -15,8 +15,8 @@ if __name__ == "__main__":
start = time.time() start = time.time()
shows = Spectacle.objects.all() shows = Spectacle.objects.all()
members = Participant.objects.all() members = Participant.objects.all()
choices = ChoixSpectacle.objects.order_by('participant', 'priority').\ choices = ChoixSpectacle.objects.order_by('participant', 'priority') \
select_related().all() .select_related().all()
available_slots = Spectacle.objects.aggregate(Sum('slots'))['slots__sum'] available_slots = Spectacle.objects.aggregate(Sum('slots'))['slots__sum']
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute( cursor.execute(