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

@ -95,7 +95,7 @@ class Display:
(0, 0, 255), # medium blue / blue (0, 0, 255), # medium blue / blue
(96, 160, 255), # light blue (96, 160, 255), # light blue
(128, 80, 0), # brown / dark orange (128, 80, 0), # brown / dark orange
(255, 128 ,0), # orange (255, 128, 0), # orange
(192, 192, 192), # gray 2 (192, 192, 192), # gray 2
(255, 144, 128), # pink / light red (255, 144, 128), # pink / light red
(0, 255, 0), # light green / green (0, 255, 0), # light green / green

View File

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

View File

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

View File

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

2
tox.ini Normal file
View File

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