mirror of
https://github.com/openbsd/ports.git
synced 2026-06-17 23:13:55 +02:00
gambatte: migrate to Python 3
Convert the solitary Python file with 2to3 and add a few more tweaks so it works under Python 3. This removes Python 2 as a dep from one more port. ok bentley@ (MAINTAINER)
This commit is contained in:
@@ -4,7 +4,7 @@ REV = 571
|
||||
V = 0.5.0.${REV}
|
||||
DISTNAME = gambatte_src-r${REV}
|
||||
PKGNAME = gambatte-$V
|
||||
REVISION = 9
|
||||
REVISION = 10
|
||||
|
||||
CATEGORIES = emulators
|
||||
|
||||
@@ -24,7 +24,7 @@ CXXFLAGS_base-clang = -std=c++14
|
||||
SITES = ${SITE_SOURCEFORGE:=gambatte/}
|
||||
|
||||
MODULES = lang/python
|
||||
MODPY_VERSION = ${MODPY_DEFAULT_VERSION_2}
|
||||
|
||||
MODPY_BUILDDEP = No
|
||||
MODPY_RUNDEP = No
|
||||
MODPY_TESTDEP = Yes
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
Adapt for Python 3.
|
||||
|
||||
Index: test/qdgbas.py
|
||||
--- test/qdgbas.py.orig
|
||||
+++ test/qdgbas.py
|
||||
@@ -8,11 +8,11 @@ class InputError(RuntimeError): pass
|
||||
Op = collections.namedtuple('Op', ['string', 'code', 'size', 'assemble'])
|
||||
|
||||
def mkrestr(s):
|
||||
- return re.sub(r'\s+', r'\s*', re.sub(r'([,)(+])', r' \\\1 ', s))
|
||||
+ return re.sub(r'\s+', r'\\s*', re.sub(r'([,)(+])', r' \\\1 ', s))
|
||||
|
||||
imm8 = r'[0-9a-fA-F][0-9a-fA-F]'
|
||||
imm16 = imm8 + imm8
|
||||
-labelregexp = re.compile('\w+\s+(\w+)')
|
||||
+labelregexp = re.compile(r'\w+\s+(\w+)')
|
||||
|
||||
def assembleNormal(outdata, outpos, indata, inpos, targets, op):
|
||||
pass
|
||||
@@ -140,7 +140,7 @@ def makeoplist():
|
||||
addop('ei', 0xfb)
|
||||
addop('cmp a, imm8', 0xfe)
|
||||
addop('srl a', 0xcb3f)
|
||||
- addop('\w* : ', -1)
|
||||
+ addop(r'\w* : ', -1)
|
||||
|
||||
return l
|
||||
|
||||
@@ -154,7 +154,7 @@ oplist = makeoplist()
|
||||
opregexp = makeopregexp(oplist)
|
||||
|
||||
def maptargets(targets, indata, instart, addr):
|
||||
- for i in xrange(instart, len(indata)):
|
||||
+ for i in range(instart, len(indata)):
|
||||
match = opregexp.match(indata[i])
|
||||
if match == None:
|
||||
break
|
||||
@@ -162,14 +162,14 @@ def maptargets(targets, indata, instart, addr):
|
||||
op = oplist[match.lastindex - 1]
|
||||
|
||||
if op.size == 0:
|
||||
- targets[re.match('(\w*)\s*:', indata[i]).group(1)] = addr
|
||||
+ targets[re.match(r'(\w*)\s*:', indata[i]).group(1)] = addr
|
||||
|
||||
addr += op.size
|
||||
|
||||
return i
|
||||
|
||||
def astext(outdata, addr, indata, instart, targets):
|
||||
- for i in xrange(instart, len(indata)):
|
||||
+ for i in range(instart, len(indata)):
|
||||
match = opregexp.match(indata[i])
|
||||
if match == None:
|
||||
break
|
||||
@@ -193,7 +193,7 @@ def astext(outdata, addr, indata, instart, targets):
|
||||
|
||||
def asdata(outdata, addr, indata, instart):
|
||||
try:
|
||||
- for i in xrange(instart, len(indata)):
|
||||
+ for i in range(instart, len(indata)):
|
||||
ints = [int(x, 0x10) for x in indata[i].split()]
|
||||
outdata[addr:addr+len(ints)] = ints
|
||||
addr += len(ints)
|
||||
@@ -222,7 +222,7 @@ def assembleFile(indata):
|
||||
size = 0x8000
|
||||
startpos = 0
|
||||
|
||||
- for i in xrange(0, len(indata)):
|
||||
+ for i in range(0, len(indata)):
|
||||
spl = indata[i].split()
|
||||
if len(spl) > 0 and spl[0] == '.size':
|
||||
size = int(spl[1], 0x10)
|
||||
@@ -276,11 +276,11 @@ def outFilenameFromInFilename(inname, h143):
|
||||
|
||||
def main():
|
||||
for arg in sys.argv[1:]:
|
||||
- print 'processing ' + arg
|
||||
+ print('processing ' + arg)
|
||||
outdata = assembleFile(readDataFromFile(arg))
|
||||
writeDataToFile(outFilenameFromInFilename(arg, outdata[0x143]), outdata)
|
||||
|
||||
- print "\nassembled " + str(len(sys.argv) - 1) + (' files' if len(sys.argv) != 2 else ' file')
|
||||
+ print("\nassembled " + str(len(sys.argv) - 1) + (' files' if len(sys.argv) != 2 else ' file'))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user