Skip to content

Commit 9a928ce

Browse files
committed
pyflakes and python3 cleanup of the website code
1 parent b04d87b commit 9a928ce

20 files changed

+89
-104
lines changed

conf/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# coding: utf8
22
import yaml
3-
from os.path import join, dirname, splitext, split
4-
from glob import glob
3+
from os.path import join, dirname
54

65
config = mirrors = packages = None
76

cont.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
IN_MODIFY = pyinotify.IN_MODIFY
1818
IN_CREATE = pyinotify.IN_CREATE
1919
IN_DELETE = pyinotify.IN_DELETE
20-
from os.path import exists, abspath
2120
import time
2221

2322

@@ -71,7 +70,7 @@ def autocompile(paths, cmd):
7170
IN_MODIFY, # but still all?!
7271
rec=True,
7372
auto_add=True)
74-
print '==> Start monitoring %s (type CTRL-c to exit)' % paths
73+
print('==> Start monitoring %s (type CTRL-c to exit)' % paths)
7574

7675
try:
7776
notifier.loop()

publish.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env bash
22
# After the website has been built successfully, it is in the "www" subdirectory.
33
# This script synchronizes this build with the Git repository at GitHub.
44
# From there, the website is served.
@@ -25,4 +25,3 @@ $GIT reset --soft github/master # <- non destructive
2525
$GIT add -A -- .
2626
$GIT commit -m "auto publish `date -u --rfc-3339=seconds`"
2727
$GIT push github master -f
28-

render.py

-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
import sys
1111
from os.path import join, normpath, exists, islink, basename, splitext
1212
from glob import glob
13-
import datetime
14-
import shutil
15-
import yaml
1613
import jinja2 as j2
17-
import multiprocessing as mp
1814
import markdown
1915

2016
from scripts import log

scripts/apache_stats.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf8 -*-
2+
# -*- coding: utf-8 -*-
33
"""
44
This file parses the boxen specific apache logfiles for www_sagemath_org
55
It generates a statistic for all SPKGes, which are not standard and
@@ -73,7 +73,7 @@ def apachetime(s):
7373

7474

7575
def analyze(logfile):
76-
print 'scanning', logfile
76+
print('scanning', logfile)
7777

7878
for line_no, line in enumerate(file(logfile, 'r')):
7979
# check if there is a newer line (newer than in the Data (data_fn) dump)

scripts/attic/old-sources-update.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
#F = os.listdir(PATH)
1919
#G = [(os.path.getctime(f), f) for f in F]
20-
#print G
20+
#print(G)
2121
#G.sort(reverse=True)
22-
#print "-----\n\n"
23-
#print G
22+
#print("-----\n\n")
23+
#print(G)
2424
#F = [f for _, f in G]
2525

2626
#F.sort()
@@ -68,7 +68,7 @@
6868
size = int(os.path.getsize(PATH + "/" + x)/1000000)
6969
if x == "sage.tar.bz2" or not x[:5] == 'sage-':
7070
continue
71-
print x
71+
print(x)
7272
name = x.replace("_"," ").replace("sage-","")
7373
i = name.find("-src")
7474
if i != -1:

scripts/attic/source_download.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Populate all the source code releases inside download-source.html
44
"""
55

6-
print "no longer used"
6+
print("no longer used")
77
import sys
88
sys.exit(0)
99

@@ -23,7 +23,7 @@
2323
table_body = None
2424

2525
if not os.path.exists(src_html):
26-
print 'File Not Found: %s' % src_html
26+
print('File Not Found: %s' % src_html)
2727
sys.exit(1)
2828

2929
source_xml = minidom.parse(src_html)
@@ -34,14 +34,14 @@
3434
source = d
3535

3636
if source is None:
37-
print '<div id="source">...</div> not found!'
37+
print('<div id="source">...</div> not found!')
3838
sys.exit(1)
3939

4040
def initContent():
4141
global table_body
4242
#delete everything
4343
for o in source_xml.getElementsByTagName(r'table'):
44-
print "deleting", o
44+
print("deleting", o)
4545
o.parentNode.removeChild(o)
4646
table = source_xml.createElement(r'table')
4747
table.setAttribute(r'class', 'xsmall')
@@ -81,7 +81,7 @@ def writeToSource():
8181
tr = source_xml.createElement(r'tr')
8282
if first:
8383
tr.setAttribute(r'class','first')
84-
first = False
84+
first = False
8585
elif release % 2 == 0:
8686
tr.setAttribute(r'class', 'even')
8787
else:
@@ -92,7 +92,7 @@ def writeToSource():
9292
tr.appendChild(td)
9393

9494
td = source_xml.createElement(r'td')
95-
print name
95+
print(name)
9696
a = source_xml.createElement(r'a')
9797
a.setAttribute(r'href', F.replace(os.path.sep + r'www', ''))
9898
a.appendChild(source_xml.createTextNode(name))
@@ -135,7 +135,7 @@ def writeToSource():
135135
tr.appendChild(td)
136136

137137
td = source_xml.createElement(r'td')
138-
print name, F
138+
print(name, F)
139139
a = source_xml.createElement(r'a')
140140
a.setAttribute(r'href', 'http://www.sagemath.org/src-old' + F.replace(src_old, ''))
141141
a.appendChild(source_xml.createTextNode(name))
@@ -156,7 +156,7 @@ def writeToSource():
156156
initContent()
157157
writeToSource()
158158

159-
#print source_xml.toxml()
159+
#print(source_xml.toxml())
160160
#xml.dom.ext.PrettyPrint(source_xml, open(src_html, 'w'))
161161

162162
source_xml.writexml(utils.UnicodeFileWriter( open(src_html, "w")))

scripts/export.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def usage():
5151
"""
5252
Print the usage information for this script.
5353
"""
54-
print "".join(["Usage: ", sys.argv[0], " /path/to/SAGE_ROOT/"])
54+
print("".join(["Usage: ", sys.argv[0], " /path/to/SAGE_ROOT/"]))
5555
sys.stdout.flush()
5656

5757
##############################

scripts/geocode.py

+19-18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
BUGS:
1313
* devcloud tag get's shortend, firefox&co cannot cope with it :( ... make it full again
1414
"""
15+
from __future__ import print_function
1516

1617
import xml.dom.minidom as minidom
1718
from xml.dom.minidom import parse, parseString
@@ -180,9 +181,9 @@ def getGeo(loc):
180181
"""
181182
loc = loc.replace(" ", "+")
182183
loc = urllib2.quote(loc.encode('UTF-8'))
183-
print loc, ">>>",
184+
print(loc, ">>>", end="")
184185
global timeout
185-
print "[doing query, %s secs break] >>>" % timeout,
186+
print("[doing query, %s secs break] >>>" % timeout, end="")
186187
sys.stdout.flush()
187188
time.sleep(timeout)
188189
#url = 'http://maps.google.com/maps/geo?q=%s&output=csv&key=%s' % (loc, gkey)
@@ -199,7 +200,7 @@ def getGeo(loc):
199200
loc = geo["results"][0]["geometry"]["location"]
200201
lng = str(loc["lng"])
201202
lat = str(loc["lat"])
202-
print acc, lat, lng
203+
print(acc, lat, lng)
203204
return "200", acc, lng, lat
204205

205206

@@ -209,19 +210,19 @@ def addGeo(place):
209210
if not lcache:
210211
geo = getGeo(place)
211212
while geo is None and attempts > 0:
212-
print "[no result, trying again] >>>",
213+
print("[no result, trying again] >>>", end="")
213214
sys.stdout.flush()
214215
geo = getGeo(place)
215216
attempts -= 1
216217
if geo is None and attempts == 0:
217-
print "FAILURE AFTER TOO MANY ATTEMPTS"
218+
print("FAILURE AFTER TOO MANY ATTEMPTS")
218219
return
219220
g = outxml.createElement("loc")
220221
statuscode = geo[0]
221222
# http://code.google.com/apis/maps/documentation/reference.html#GGeoStatusCode
222223
# 620 means too fast, we need to slow down!
223224
if "620" == statuscode:
224-
print "we were too fast, error code 620 by google!"
225+
print("we were too fast, error code 620 by google!")
225226
global timeout
226227
timeout *= 2
227228
addGeo(place)
@@ -234,7 +235,7 @@ def addGeo(place):
234235
g.setAttribute("loclat", geo[3])
235236
out.appendChild(g)
236237
else:
237-
print "cache"
238+
print("cache")
238239
out.appendChild(lcache)
239240

240241

@@ -247,34 +248,34 @@ def getStatistics():
247248
# c.replaceChild(devmap.createTextNode(str(nbContribs)), c.childNodes[0])
248249
# elif c.getAttribute("id") == "contrib-places":
249250
# c.replaceChild(devmap.createTextNode(str(nbPlaces)), c.childNodes[0])
250-
print "contributors =", str(nbContribs), "places =", str(nbPlaces)
251+
print("contributors =", str(nbContribs), "places =", str(nbPlaces))
251252
return nbContribs, nbPlaces
252253

253254
# read through ack.xml
254255
for c in ack.getElementsByTagName("contributor"):
255-
print c.getAttribute("name"), ">>>",
256+
print(c.getAttribute("name"), ">>>", end="")
256257
if c.hasAttribute("location"):
257258
addGeo(c.getAttribute("location"))
258259
else:
259-
print " <--- UNKNOWN LOCATION !!!"
260+
print(" <--- UNKNOWN LOCATION !!!")
260261

261262

262-
print
263-
print "This is now written to file %s:" % geocode_xml_outfn
264-
print out.toprettyxml()
263+
print()
264+
print("This is now written to file %s:" % geocode_xml_outfn)
265+
print(out.toprettyxml())
265266

266267
#xml.dom.ext.PrettyPrint(out, open(geocode_xml_outfn, "w"))
267268
out.writexml(utils.UnicodeFileWriter(open(geocode_xml_outfn, "w")), newl="\n")
268269

269-
print
270-
print "calculating statistics and writing to description"
270+
print()
271+
print("calculating statistics and writing to description")
271272
nbContribs, nbPlaces = getStatistics()
272273

273-
print
274-
print "now writing table entries for search engines and javascript disabled ones"
274+
print()
275+
print("now writing table entries for search engines and javascript disabled ones")
275276
writeToDevmap()
276277

277-
print "file written to %s" % devmap_tmpl
278+
print("file written to %s" % devmap_tmpl)
278279
#xml.dom.ext.PrettyPrint(devmap, open(devmap_xml, "w"))
279280
#devmap.writexml(utils.UnicodeFileWriter(open(devmap_tmpl, "w")), newl="\n")
280281
# utils.delFirstLine(devmap_xml)

scripts/index-documentation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
for link in sp.Popen("find -type l -name _static".split(), stdout=sp.PIPE).stdout:
5252
d = os.path.normpath(os.path.join(ROOT, link.rsplit("/", 1)[0]))
53-
print d
53+
print(d)
5454
os.chdir(d)
5555
os.system(
5656
r'find -type f -name "*.html" -exec sed -i "s/_static/..\/_static/" {} \;')

0 commit comments

Comments
 (0)