PEP8 compliance

This commit is contained in:
James Tauber 2014-07-15 11:29:11 -04:00
parent d340d9cb5f
commit 934bf1a495
6 changed files with 59 additions and 46 deletions

View File

@ -68,7 +68,7 @@ def run(win):
"--rom", options.rom,
]
p = subprocess.Popen(args)
subprocess.Popen(args)
cpu, _ = listener.accept()
win.clear()

View File

@ -1,16 +1,18 @@
import json
import readline
import sys
import urllib
URL_PREFIX = "http://localhost:6502"
def get(url):
return json.loads(urllib.urlopen(URL_PREFIX + url).read())
def post(url, data=None):
return urllib.urlopen(URL_PREFIX + url, json.dumps(data) if data is not None else "")
def value(s):
if s.startswith("$"):
return int(s[1:], 16)
@ -18,6 +20,7 @@ def value(s):
return int(s[2:], 16)
return int(s)
def format_disassemble(dis):
r = "%04X- " % dis["address"]
for i in range(3):
@ -32,6 +35,7 @@ def format_disassemble(dis):
r += "[%04X] = %0*X" % tuple(dis["memory"])
return r
def cmd_disassemble(a):
"""Disassemble"""
if len(a) > 1:
@ -43,6 +47,7 @@ def cmd_disassemble(a):
for d in disasm:
print format_disassemble(d)
def cmd_dump(a):
"""Dump memory"""
start = value(a[1])
@ -78,6 +83,7 @@ def cmd_dump(a):
print s
addr += 16
def cmd_help(a):
"""Help commands"""
if len(a) > 1:
@ -91,18 +97,21 @@ def cmd_help(a):
for c in sorted(Commands):
print " ", c
def cmd_peek(a):
"""Peek memory location"""
addr = value(a[1])
dump = get("/memory/%d" % addr)
print "%04X: %02X" % (addr, dump[0])
def cmd_poke(a):
"""Poke memory location"""
addr = value(a[1])
val = value(a[2])
post("/memory/%d" % addr, [val])
def cmd_status(a):
"""CPU status"""
status = get("/status")
@ -123,10 +132,12 @@ def cmd_status(a):
disasm = get("/disassemble/%d" % status["program_counter"])
print format_disassemble(disasm[0])
def cmd_quit(a):
"""Quit"""
sys.exit(0)
def cmd_reset(a):
"""Reset"""
post("/reset")
@ -142,6 +153,7 @@ Commands = {
"reset": cmd_reset,
}
def main():
print "ApplePy control console"
while True:

View File

@ -1166,7 +1166,6 @@ class CPU:
self.status_from_byte(self.pull_byte())
self.program_counter = self.pull_word()
# @@@ IRQ
# @@@ NMI

2
tox.ini Normal file
View File

@ -0,0 +1,2 @@
[flake8]
ignore = E265,E501