change files to work with python3 (#7)

This commit is contained in:
Gh057y 2024-05-27 22:52:10 +02:00 committed by GitHub
parent cf0b2bba0f
commit ae24e5a753
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 39 additions and 35 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
import sys,string,time import sys,string,time
sys.path.append('../internal') sys.path.append('../internal')
@ -8,7 +8,7 @@ months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'] 'August', 'September', 'October', 'November', 'December']
for epnum in sys.argv[1:]: for epnum in sys.argv[1:]:
curep = string.atoi(epnum[:3]) curep = int(epnum[:3])
curepno = curep curepno = curep
cureplong = '%03d' % (curep) cureplong = '%03d' % (curep)
prevep = '%03d' % (curep - 1) prevep = '%03d' % (curep - 1)
@ -21,7 +21,7 @@ for epnum in sys.argv[1:]:
if epname == '': if epname == '':
epname = 'XXX' epname = 'XXX'
curep = `curep` curep = repr(curep)
input = open('story.html', 'r') input = open('story.html', 'r')
output = open(cureplong + '.shtml', 'w') output = open(cureplong + '.shtml', 'w')
@ -50,12 +50,12 @@ for epnum in sys.argv[1:]:
if line == '': if line == '':
break break
if line[:8] == '<episode': if line[:8] == '<episode':
thisep = string.atoi(line[-5:-2]) thisep = int(line[-5:-2])
if thisep > max_summary: if thisep > max_summary:
if not printing: if not printing:
output.write('<!--#include virtual="') output.write('<!--#include virtual="')
output.write('/lurk/background/sum-' + output.write('/lurk/background/sum-' +
`max_summary` + '" -->\n') repr(max_summary) + '" -->\n')
if thisep < curepno: if thisep < curepno:
output.write('<h1>More ' + output.write('<h1>More ' +
@ -90,4 +90,4 @@ Last update:
input.close() input.close()
output.close() output.close()
print epnum print(epnum)

View File

@ -9,4 +9,4 @@ while ($ep < $toteps)
@ ep++ @ ep++
end end
gen.py $list ./gen.py $list

View File

@ -1,2 +1,2 @@
#!/bin/csh #!/bin/csh
gen.py [01]?? ./gen.py [01]??

View File

@ -1,4 +1,4 @@
#!/usr/local/bin/python #!/usr/local/bin/python3
import sys,string import sys,string
sys.path.append('../internal') sys.path.append('../internal')
@ -28,7 +28,7 @@ output.write("""<html>
for i in range(0, 200): for i in range(0, 200):
filename = "%03d" % i filename = "%03d" % i
print filename print(filename)
try: try:
handle = open(filename, 'r') handle = open(filename, 'r')
handle.close() handle.close()

View File

@ -1,4 +1,4 @@
#!/usr/local/bin/python #!/usr/local/bin/python3
import sys,string import sys,string
sys.path.append('../internal') sys.path.append('../internal')
@ -39,4 +39,4 @@ October 8, 1995
</html> </html>
""" """
print output print(output)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
import sys,string,time,os import sys,string,time,os
sys.path.append('../internal') sys.path.append('../internal')
@ -13,7 +13,8 @@ do_jpeg = perdir.get_do_jpeg()
args = sys.argv args = sys.argv
for epnum in args[1:]: for epnum in args[1:]:
curep = string.atoi(epnum[:3]) # curep = string.atoi(epnum[:3])
curep = int(epnum[:3])
pix = open(perdir.get_episode_names_file(), 'r') pix = open(perdir.get_episode_names_file(), 'r')
for i in range(0, curep + 1): for i in range(0, curep + 1):
@ -82,7 +83,7 @@ for epnum in args[1:]:
rewrite = open('@' + epnum, 'w') rewrite = open('@' + epnum, 'w')
needsupdate = 0 needsupdate = 0
pieces = string.splitfields(wholefile, '@@@') pieces = wholefile.split('@@@')
final = pieces[0] final = pieces[0]
rewrite.write(pieces[0]) rewrite.write(pieces[0])
@ -95,8 +96,9 @@ for epnum in args[1:]:
if timestamp == 0: if timestamp == 0:
needsupdate = 1 needsupdate = 1
timestamp = int(time.time()) timestamp = int(time.time())
rewrite.write('@@@' + `timestamp`) rewrite.write('@@@' + repr(timestamp))
rewrite.write(piece[string.index(piece, ' '):]) #rewrite.write(piece[string.index(piece, ' '):])
rewrite.write(piece[piece.index(' '):])
else: else:
rewrite.write('@@@' + piece) rewrite.write('@@@' + piece)
@ -105,7 +107,8 @@ for epnum in args[1:]:
final = final + ('<strong>[[%d/%d]]</strong>' % final = final + ('<strong>[[%d/%d]]</strong>' %
(timeval[1], timeval[2])); (timeval[1], timeval[2]));
final = final + piece[string.index(piece, ' '):] #final = final + piece[string.index(piece, ' '):]
final = final + piece[piece.index(' '):]
rewrite.close() rewrite.close()
if needsupdate: if needsupdate:
@ -139,7 +142,7 @@ for epnum in args[1:]:
output.close() output.close()
if do_jpeg: if do_jpeg:
print epnum, 'jpeg' print((epnum, 'jpeg'))
else: else:
print epnum print(epnum)

View File

@ -1,4 +1,4 @@
#!/usr/local/bin/python #!/usr/local/bin/python3
import sys,string,time,os import sys,string,time,os
sys.path.append('../internal') sys.path.append('../internal')
@ -8,7 +8,7 @@ months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'] 'August', 'September', 'October', 'November', 'December']
for epnum in sys.argv[1:]: for epnum in sys.argv[1:]:
curep = string.atoi(epnum[:3]) curep = int(epnum[:3])
pix = open('../internal/epnames', 'r') pix = open('../internal/epnames', 'r')
for i in range(0, curep + 1): for i in range(0, curep + 1):
@ -84,13 +84,13 @@ for epnum in sys.argv[1:]:
rewrite = open('@' + epnum, 'w') rewrite = open('@' + epnum, 'w')
needsupdate = 0 needsupdate = 0
pieces = string.splitfields(wholefile, '@@@') pieces = wholefile.split('@@@')
output.write(pieces[0]) output.write(pieces[0])
rewrite.write(pieces[0]) rewrite.write(pieces[0])
for piece in pieces[1:]: for piece in pieces[1:]:
try: try:
timestamp =string.atoi(piece[:string.index(piece, ' ')]) timestamp =int(piece[:string.index(piece, ' ')])
except: except:
timestamp = 0 timestamp = 0

View File

@ -1,2 +1,2 @@
#!/bin/csh #!/bin/csh
gen.py `/bin/ls [012345]* | fgrep -v .html` ./gen.py `/bin/ls [012345]* | fgrep -v .html`

View File

@ -1,10 +1,10 @@
#!/usr/local/bin/python #!/usr/local/bin/python3
import sys,string import sys,string
sys.path.append('../internal') sys.path.append('../internal')
import otros import otros
curep = string.atoi(sys.argv[1]) curep = int(sys.argv[1])
if len(sys.argv) == 3: if len(sys.argv) == 3:
output = otros.pageheader(curep, 'other') output = otros.pageheader(curep, 'other')
@ -26,4 +26,4 @@ if len(sys.argv) != 3:
<hr> <hr>
""" """
print output print(output)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python33
# #
# Per-directory values for /lurk/guide # Per-directory values for /lurk/guide
# #

View File

@ -136,7 +136,7 @@ def pageheader(num, page, do_jpeg = 0):
else: else:
picname = cureplong + '/' + picname picname = cureplong + '/' + picname
curep = `curep` curep = repr(curep)
picwidth = 500 - titlewidth picwidth = 500 - titlewidth
output = """ output = """
@ -156,14 +156,14 @@ def pageheader(num, page, do_jpeg = 0):
extension = '.gif' extension = '.gif'
output = output + """<img output = output + """<img
align=middle width=""" + `picwidth` + """ height=120 border=0 align=middle width=""" + repr(picwidth) + """ height=120 border=0
src="/lurk/gif/""" + picname + extension + '" alt="">' src="/lurk/gif/""" + picname + extension + '" alt="">'
if page == 'comic' or page == 'novels': if page == 'comic' or page == 'novels':
output = output + '</a>' output = output + '</a>'
output = output + """<img output = output + """<img
align=middle width=""" + `titlewidth` + """ height=120 align=middle width=""" + repr(titlewidth) + """ height=120
src="/lurk/gif/titles/""" + titleprefix + curep + """.gif" src="/lurk/gif/titles/""" + titleprefix + curep + """.gif"
alt=""> alt="">
@ -311,8 +311,9 @@ def mungeimages(text, do_jpeg):
result = '' result = ''
for chunk in string.splitfields(text, '.gif'): for chunk in text.split('.gif'):
filepos = string.rfind(chunk, '"') #filepos = string.rfind(chunk, '"')
filepos = chunk.rfind('"')
if filepos < 0: if filepos < 0:
result = result + chunk result = result + chunk
break break

View File

@ -1 +1 @@
gen.py [012]?? ./gen.py [012]??