Skip to content

Commit 03ef41a

Browse files
committed
Fix indentation
Per pep8 warnings, adjust indentation for consistency
1 parent 65b4db1 commit 03ef41a

File tree

12 files changed

+157
-167
lines changed

12 files changed

+157
-167
lines changed

django/archives/auth.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def login(request):
6565
cipher = encryptor.encrypt(s + ' ' * (16-(len(s) % 16))) # pad to 16 bytes
6666

6767
return HttpResponseRedirect("%s?d=%s$%s" % (
68-
settings.PGAUTH_REDIRECT,
69-
base64.b64encode(iv, b"-_").decode('utf8'),
70-
base64.b64encode(cipher, b"-_").decode('utf8'),
71-
))
68+
settings.PGAUTH_REDIRECT,
69+
base64.b64encode(iv, b"-_").decode('utf8'),
70+
base64.b64encode(cipher, b"-_").decode('utf8'),
71+
))
7272
else:
7373
return HttpResponseRedirect(settings.PGAUTH_REDIRECT)
7474

@@ -208,7 +208,7 @@ def user_search(searchterm=None, userid=None):
208208
u = urllib.request.urlopen('%ssearch/?%s' % (
209209
settings.PGAUTH_REDIRECT,
210210
urlencode(q),
211-
))
211+
))
212212
(ivs, datas) = u.read().split('&')
213213
u.close()
214214

django/archives/mailarchives/api.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def listinfo(request):
2323
'description': l.description,
2424
'active': l.active,
2525
'group': l.group.groupname,
26-
} for l in List.objects.select_related('group').all()], resp)
26+
} for l in List.objects.select_related('group').all()], resp)
2727

2828
return resp
2929

@@ -101,12 +101,13 @@ def thread(request, msgid):
101101

102102
resp = HttpResponse(content_type='application/json')
103103
json.dump([
104-
{'msgid': m.messageid,
105-
'date': m.date.isoformat(),
106-
'from': m.mailfrom,
107-
'subj': m.subject,
108-
'atts': [{'id': a.id, 'name': a.filename} for a in m.attachment_set.all()],
109-
}
104+
{
105+
'msgid': m.messageid,
106+
'date': m.date.isoformat(),
107+
'from': m.mailfrom,
108+
'subj': m.subject,
109+
'atts': [{'id': a.id, 'name': a.filename} for a in m.attachment_set.all()],
110+
}
110111
for m in mlist], resp)
111112
resp['X-pgthread'] = m.threadid
112113
return resp

django/archives/mailarchives/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'This message has been hidden because the message violated policies.', # 2
1010
'This message has been hidden because for privacy reasons.', # 3
1111
'This message was corrupt', # 4
12-
]
12+
]
1313

1414

1515
class Message(models.Model):

django/archives/mailarchives/views.py

+60-58
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def get_all_groups_and_lists(request, listid=None):
154154
'sortkey': l.group.sortkey,
155155
'lists': [l,],
156156
'homelink': 'list/group/%s' % l.group.groupid,
157-
}
157+
}
158158

159159
return (sorted(list(groups.values()), key=lambda g: g['sortkey']), listgroupid)
160160

@@ -193,8 +193,8 @@ def index(request):
193193

194194
(groups, listgroupid) = get_all_groups_and_lists(request)
195195
return render_nav(NavContext(request, all_groups=groups), 'index.html', {
196-
'groups': [{'groupname': g['groupname'], 'lists': g['lists']} for g in groups],
197-
})
196+
'groups': [{'groupname': g['groupname'], 'lists': g['lists']} for g in groups],
197+
})
198198

199199

200200
@cache(hours=8)
@@ -205,8 +205,8 @@ def groupindex(request, groupid):
205205
raise Http404('List group does not exist')
206206

207207
return render_nav(NavContext(request, all_groups=groups, expand_groupid=groupid), 'index.html', {
208-
'groups': mygroups,
209-
})
208+
'groups': mygroups,
209+
})
210210

211211
@cache(hours=8)
212212
def monthlist(request, listname):
@@ -218,9 +218,9 @@ def monthlist(request, listname):
218218
months=[{'year':r[0],'month':r[1], 'date':datetime(r[0],r[1],1)} for r in curs.fetchall()]
219219

220220
return render_nav(NavContext(request, l.listid, l.listname), 'monthlist.html', {
221-
'list': l,
222-
'months': months,
223-
})
221+
'list': l,
222+
'months': months,
223+
})
224224

225225
def get_monthday_info(mlist, l, d):
226226
allmonths = set([m.date.month for m in mlist])
@@ -236,10 +236,10 @@ def get_monthday_info(mlist, l, d):
236236
if monthdate:
237237
curs = connection.cursor()
238238
curs.execute("SELECT DISTINCT extract(day FROM date) FROM messages WHERE date >= %(startdate)s AND date < %(enddate)s AND threadid IN (SELECT threadid FROM list_threads WHERE listid=%(listid)s) ORDER BY 1", {
239-
'startdate': datetime(year=monthdate.year, month=monthdate.month, day=1),
240-
'enddate': monthdate + timedelta(days=calendar.monthrange(monthdate.year, monthdate.month)[1]),
241-
'listid': l.listid,
242-
})
239+
'startdate': datetime(year=monthdate.year, month=monthdate.month, day=1),
240+
'enddate': monthdate + timedelta(days=calendar.monthrange(monthdate.year, monthdate.month)[1]),
241+
'listid': l.listid,
242+
})
243243
daysinmonth = [int(r[0]) for r in curs.fetchall()]
244244

245245
yearmonth = None
@@ -265,12 +265,12 @@ def _render_datelist(request, l, d, datefilter, title, queryproc):
265265
(yearmonth, daysinmonth) = get_monthday_info(mlist, l, d)
266266

267267
r = render_nav(NavContext(request, l.listid, l.listname), 'datelist.html', {
268-
'list': l,
269-
'messages': mlist,
270-
'title': title,
271-
'daysinmonth': daysinmonth,
272-
'yearmonth': yearmonth,
273-
})
268+
'list': l,
269+
'messages': mlist,
270+
'title': title,
271+
'daysinmonth': daysinmonth,
272+
'yearmonth': yearmonth,
273+
})
274274
r['X-pglm'] = ':%s:' % (':'.join(['%s/%s/%s' % (l.listid, year, month) for year,month in allyearmonths]))
275275
return r
276276

@@ -379,7 +379,8 @@ def _build_thread_structure(threadid):
379379

380380
def _get_nextprevious(listmap, dt):
381381
curs = connection.cursor()
382-
curs.execute("""WITH l(listid) AS (
382+
curs.execute("""
383+
WITH l(listid) AS (
383384
SELECT unnest(%(lists)s)
384385
)
385386
SELECT l.listid,1,
@@ -394,10 +395,11 @@ def _get_nextprevious(listmap, dt):
394395
INNER JOIN list_threads lt ON lt.threadid=m.threadid
395396
WHERE m.date<%(time)s AND lt.listid=l.listid
396397
ORDER BY m.date DESC LIMIT 1
397-
) FROM l""", {
398-
'lists': list(listmap.keys()),
399-
'time': dt,
400-
})
398+
) FROM l""",
399+
{
400+
'lists': list(listmap.keys()),
401+
'time': dt,
402+
})
401403
retval = {}
402404
for listid, isnext, data in curs.fetchall():
403405
if data:
@@ -408,13 +410,13 @@ def _get_nextprevious(listmap, dt):
408410
'date': data[1],
409411
'subject': data[2],
410412
'from': data[3],
411-
}
413+
}
412414
if listname in retval:
413415
retval[listname][isnext and 'next' or 'prev'] = d
414416
else:
415417
retval[listname] = {
416418
isnext and 'next' or 'prev': d
417-
}
419+
}
418420
return retval
419421

420422
@cache(hours=4)
@@ -447,13 +449,13 @@ def message(request, msgid):
447449
nextprev = _get_nextprevious(listmap, m.date)
448450

449451
r = render_nav(NavContext(request, lists[0].listid, lists[0].listname), 'message.html', {
450-
'msg': m,
451-
'threadstruct': threadstruct,
452-
'responses': responses,
453-
'parent': parent,
454-
'lists': lists,
455-
'nextprev': nextprev,
456-
})
452+
'msg': m,
453+
'threadstruct': threadstruct,
454+
'responses': responses,
455+
'parent': parent,
456+
'lists': lists,
457+
'nextprev': nextprev,
458+
})
457459
r['X-pgthread'] = ":%s:" % m.threadid
458460
r['Last-Modified'] = http_date(newest)
459461
return r
@@ -478,11 +480,11 @@ def message_flat(request, msgid):
478480
return HttpResponseNotModified()
479481

480482
r = render_nav(NavContext(request), 'message_flat.html', {
481-
'msg': msg,
482-
'allmsg': allmsg,
483-
'lists': lists,
484-
'isfirst': isfirst,
485-
})
483+
'msg': msg,
484+
'allmsg': allmsg,
485+
'lists': lists,
486+
'isfirst': isfirst,
487+
})
486488
r['X-pgthread'] = ":%s:" % msg.threadid
487489
r['Last-Modified'] = http_date(newest)
488490
return r
@@ -572,9 +574,9 @@ def mbox(request, listname, listname2, mboxyear, mboxmonth):
572574

573575
query = "SELECT messageid, rawtxt FROM messages m INNER JOIN list_threads t ON t.threadid=m.threadid WHERE listid=%(listid)s AND hiddenstatus IS NULL AND date >= %(startdate)s AND date <= %(enddate)s %%% ORDER BY date"
574576
params = {
575-
'listid': l.listid,
576-
'startdate': date(mboxyear, mboxmonth, 1),
577-
'enddate': datetime(mboxyear, mboxmonth, calendar.monthrange(mboxyear, mboxmonth)[1], 23, 59, 59),
577+
'listid': l.listid,
578+
'startdate': date(mboxyear, mboxmonth, 1),
579+
'enddate': datetime(mboxyear, mboxmonth, calendar.monthrange(mboxyear, mboxmonth)[1], 23, 59, 59),
578580
}
579581

580582
if not settings.PUBLIC_ARCHIVES and not request.user.is_superuser:
@@ -647,8 +649,8 @@ def search(request):
647649
# We don't do a more specific check if it's a messageid because doing
648650
# a key lookup is cheap...
649651
curs.execute("SELECT messageid FROM messages WHERE messageid=%(q)s", {
650-
'q': query,
651-
})
652+
'q': query,
653+
})
652654
a = curs.fetchall()
653655
if len(a) == 1:
654656
# Yup, this was a messageid
@@ -680,16 +682,16 @@ def search(request):
680682

681683
resp = HttpResponse(content_type='application/json')
682684

683-
json.dump([{
684-
'm': messageid,
685-
'd': date.isoformat(),
686-
's': subject,
687-
'f': mailfrom,
688-
'r': rank,
689-
'a': abstract.replace("[[[[[[", "<b>").replace("]]]]]]","</b>"),
690-
691-
} for messageid, date, subject, mailfrom, rank, abstract in curs.fetchall()],
692-
resp)
685+
json.dump([
686+
{
687+
'm': messageid,
688+
'd': date.isoformat(),
689+
's': subject,
690+
'f': mailfrom,
691+
'r': rank,
692+
'a': abstract.replace("[[[[[[", "<b>").replace("]]]]]]","</b>"),
693+
} for messageid, date, subject, mailfrom, rank, abstract in curs.fetchall()],
694+
resp)
693695
return resp
694696

695697
@cache(seconds=10)
@@ -703,11 +705,11 @@ def web_sync_timestamp(request):
703705
def legacy(request, listname, year, month, msgnum):
704706
curs = connection.cursor()
705707
curs.execute("SELECT msgid FROM legacymap WHERE listid=(SELECT listid FROM lists WHERE listname=%(list)s) AND year=%(year)s AND month=%(month)s AND msgnum=%(msgnum)s", {
706-
'list': listname,
707-
'year': year,
708-
'month': month,
709-
'msgnum': msgnum,
710-
})
708+
'list': listname,
709+
'year': year,
710+
'month': month,
711+
'msgnum': msgnum,
712+
})
711713
r = curs.fetchall()
712714
if len(r) != 1:
713715
raise Http404('Message does not exist')
@@ -723,7 +725,7 @@ def legacy(request, listname, year, month, msgnum):
723725
'media/css/table.css',
724726
'media/css/text.css',
725727
'media/css/docs.css'],
726-
}
728+
}
727729

728730
@cache(hours=8)
729731
def dynamic_css(request, css):

django/archives/settings.py

-14
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@
8787

8888
MIDDLEWARE_CLASSES = [
8989
'django.middleware.common.CommonMiddleware',
90-
# 'django.contrib.sessions.middleware.SessionMiddleware',
91-
# 'django.middleware.csrf.CsrfViewMiddleware',
92-
# 'django.contrib.auth.middleware.AuthenticationMiddleware',
93-
# 'django.contrib.messages.middleware.MessageMiddleware',
9490
]
9591

9692
ROOT_URLCONF = 'archives.urls'
@@ -112,16 +108,6 @@
112108

113109

114110
INSTALLED_APPS = [
115-
# 'django.contrib.auth',
116-
# 'django.contrib.contenttypes',
117-
# 'django.contrib.sessions',
118-
# 'django.contrib.sites',
119-
# 'django.contrib.messages',
120-
# 'django.contrib.staticfiles',
121-
# Uncomment the next line to enable the admin:
122-
# 'django.contrib.admin',
123-
# Uncomment the next line to enable admin documentation:
124-
# 'django.contrib.admindocs',
125111
'archives.mailarchives',
126112
]
127113

django/archives/urls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
url(r'^list/([\w-]+|\*)/latest.json$', archives.mailarchives.api.latest),
5555
url(r'^message-id.json/(.+)$', archives.mailarchives.api.thread),
5656
url(r'^listinfo/$', archives.mailarchives.api.listinfo),
57-
# url(r'^thread/(.+)/subscribe/$', archives.mailarchives.api.thread_subscribe),
57+
# url(r'^thread/(.+)/subscribe/$', archives.mailarchives.api.thread_subscribe),
5858

5959
# Legacy forwarding from old archives site
6060
url(r'^message-id/legacy/([\w-]+)/(\d+)-(\d+)/msg(\d+).php$', archives.mailarchives.views.legacy),

loader/clean_date.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ def scan_message(messageid, olddate, curs):
5353
x = input("Parsed this as date %s. Update? " % d)
5454
if x.upper() == 'Y':
5555
curs.execute("UPDATE messages SET date=%(d)s WHERE messageid=%(m)s", {
56-
'd': d,
57-
'm': messageid,
58-
})
56+
'd': d,
57+
'm': messageid,
58+
})
5959
print("Updated.")
6060
break
6161
elif x.upper() == 'N':
6262
break
63-
63+
6464
if __name__ == "__main__":
6565
cfg = ConfigParser()
6666
cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))

loader/lib/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def html_clean(self, html):
541541
'char-encoding': 'utf8',
542542
'show-warnings': 0,
543543
'show-info': 0,
544-
})
544+
})
545545
if errors:
546546
print(("HTML tidy failed for %s!" % self.msgid))
547547
print(errors)

0 commit comments

Comments
 (0)