Skip to content

Commit 07488f8

Browse files
committed
some pep details in scripts
1 parent a363d76 commit 07488f8

8 files changed

+27
-29
lines changed

scripts/attic/old-source-list-update.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
open("LATEST",'w').write(G[0])
2626

2727
g = open(PATH+"/index.html","w")
28-
g.write("""<html><head>
29-
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
30-
<title>Sage Source Distribution</title>
28+
g.write("""<html><head><meta http-equiv="content-type" content="text/html;charset=iso-8859-1"><title>Sage Source Distribution</title>
3129
<LINK REL=STYLESHEET TYPE="text/css"
3230
HREF="/was.css" TITLE="was">
3331
</head>

scripts/attic/old-sources-update.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
F = [x for x in F if x.find(".py") == -1 and x.find(".html") == -1 and x != "sageonly.tar.gz" and x.find("build_times") == -1 and x.find("README")==-1]
3030

3131
g = open(PATH+"/index.html","w")
32-
g.write("""<html><head>
33-
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
34-
<title>SAGE Source Distribution</title>
32+
g.write("""<html><head><meta http-equiv="content-type" content="text/html;charset=iso-8859-1"><title>SAGE Source Distribution</title>
3533
<LINK REL=STYLESHEET TYPE="text/css"
3634
HREF="/was.css" TITLE="was">
3735
</head>

scripts/attic/source_download.py

+15-17
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
print('File Not Found: %s' % src_html)
2727
sys.exit(1)
2828

29-
source_xml = minidom.parse(src_html)
29+
source_xml = minidom.parse(src_html)
3030
source = None #this is the target <div id="source">...</div>
3131
divs = source_xml.getElementsByTagName(r'div')
3232
for d in divs:
@@ -77,7 +77,7 @@ def writeToSource():
7777
size = int(os.path.getsize(F)/(2**20))
7878
date = time.strftime('%Y-%m-%d', FnD[0])
7979
name = F.split(os.path.sep)[-1]
80-
80+
8181
tr = source_xml.createElement(r'tr')
8282
if first:
8383
tr.setAttribute(r'class','first')
@@ -86,27 +86,27 @@ def writeToSource():
8686
tr.setAttribute(r'class', 'even')
8787
else:
8888
tr.setAttribute(r'class', 'odd')
89-
89+
9090
td = source_xml.createElement(r'td')
9191
td.appendChild(source_xml.createTextNode(str(release)))
9292
tr.appendChild(td)
93-
93+
9494
td = source_xml.createElement(r'td')
9595
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))
9999
td.appendChild(a)
100-
tr.appendChild(td)
101-
100+
tr.appendChild(td)
101+
102102
td = source_xml.createElement(r'td')
103103
td.appendChild(source_xml.createTextNode('%s MB'%size))
104104
tr.appendChild(td)
105-
105+
106106
td = source_xml.createElement(r'td')
107107
td.appendChild(source_xml.createTextNode(date))
108108
tr.appendChild(td)
109-
109+
110110
table_body.appendChild(tr)
111111
release -= 1
112112

@@ -123,33 +123,33 @@ def writeToSource():
123123
size = int(os.path.getsize(F)/(2**20))
124124
date = time.strftime('%Y-%m-%d', FnD[0])
125125
name = F.split(os.path.sep)[-1]
126-
126+
127127
tr = source_xml.createElement(r'tr')
128128
if release % 2 == 0:
129129
tr.setAttribute(r'class', 'even')
130130
else:
131131
tr.setAttribute(r'class', 'odd')
132-
132+
133133
td = source_xml.createElement(r'td')
134134
td.appendChild(source_xml.createTextNode(str(release)))
135135
tr.appendChild(td)
136-
136+
137137
td = source_xml.createElement(r'td')
138138
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))
142142
td.appendChild(a)
143-
tr.appendChild(td)
144-
143+
tr.appendChild(td)
144+
145145
td = source_xml.createElement(r'td')
146146
td.appendChild(source_xml.createTextNode('%s MB'%size))
147147
tr.appendChild(td)
148-
148+
149149
td = source_xml.createElement(r'td')
150150
td.appendChild(source_xml.createTextNode(date))
151151
tr.appendChild(td)
152-
152+
153153
table_body.appendChild(tr)
154154
release -= 1
155155

@@ -161,6 +161,4 @@ def writeToSource():
161161

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

164-
165164
#utils.delFirstLine(src_html)
166-

scripts/mirror-index.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,14 @@ def index(root, strip):
142142
isNewer = os.path.getmtime(f) > knownMd5['__MTIME__']
143143
if isNewer:
144144
delMd5Entry(dir, fn)
145-
if knownMd5.has_key(fn) and not isNewer:
145+
if fn in knownMd5 and not isNewer:
146146
trMd5 = getMd5Row(listxml, knownMd5[fn], shortdir, fn, f)
147147
else:
148148
trMd5 = getMd5Row(listxml, calcMd5(dir, fn), shortdir, fn, f)
149149
else:
150150
trMd5 = getMd5Row(listxml, None, shortdir, fn, f)
151151
table.appendChild(trMd5)
152152

153-
154153
output.appendChild(table)
155154
output.appendChild(trackPageView(listxml, shortdir))
156155
output_file = os.path.join(dir, listfile)

scripts/update_components.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
raise Exception("update_components is half/half broken. It did rely on the spkges but what still should work is the list of components from the yaml config file.")
3737

3838
COMP_PAGE = abspath(join("..", "templates", "components.html"))
39-
#STANDARD_DIR = abspath("../www/packages/standard")
39+
# STANDARD_DIR = abspath("../www/packages/standard")
4040
PACKAGES_YAML = yaml.load(open(join("..", "conf", "packages.yaml")))
4141
# dictionaries of current packages
4242
# Each package is described by the format
@@ -172,13 +172,14 @@ def usage():
172172
# the script starts here
173173
##############################
174174

175+
175176
if __name__ == "__main__":
176177
# sanity checks
177178
if len(sys.argv) != 1:
178179
# this script currently doesn't accept any argument
179180
usage()
180181
sys.exit(1)
181-
#if not os.path.isdir(STANDARD_DIR):
182+
# if not os.path.isdir(STANDARD_DIR):
182183
# print("Invalid standard spkg repository directory %s. Exiting..." % STANDARD_DIR)
183184
# sys.stdout.flush()
184185
# sys.exit(1)

scripts/updatedoc.py

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
SAGE_SAGE = None
8989
SAGE_VERSION = None
9090

91+
9192
def delete_previous_doc(target_dir):
9293
"""
9394
Delete the previous version of the Sage standard documentation.
@@ -111,6 +112,7 @@ def delete_previous_doc(target_dir):
111112
os.system("rm -rf doc-zip")
112113
os.system("rm html pdf")
113114

115+
114116
def update_doc(current_dir, target_dir, doc_tarball, filename, sage_version):
115117
"""
116118
Update the website with the current version of the Sage standard

src/files/loadtest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
print("hi from the net")
22

3-
print(2+3)
3+
print(2 + 3)

test.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class CheckTemplates(unittest.TestCase):
1313
@classmethod
1414
def setUpClass(cls):
1515
cls.templates = []
16-
ishtml = lambda _: _.endswith(".html")
16+
17+
def ishtml(f):
18+
return f.endswith(".html")
1719
for root, _, files in os.walk(SRC):
1820
cls.templates.extend(filter(ishtml, files))
1921

0 commit comments

Comments
 (0)