summaryrefslogtreecommitdiff
path: root/romstr.py
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-03-21 15:15:42 -0500
committerBryan Bishop <kanzure@gmail.com>2013-03-21 15:15:42 -0500
commitfbd4277bc8ded7637a60746e0054f9f05ee7cb72 (patch)
tree8d9493de5a1a870c973818b6effaa7ef3171a7d6 /romstr.py
parenta87132850524ef9ed657f13bfe3f4c06917cc44b (diff)
fix docstring formatting everywhere
original-commit-id: 4332a25bd5f6f80975f762d126e92064c756f7d4
Diffstat (limited to 'romstr.py')
-rw-r--r--romstr.py49
1 files changed, 30 insertions, 19 deletions
diff --git a/romstr.py b/romstr.py
index 5701f19..90c099f 100644
--- a/romstr.py
+++ b/romstr.py
@@ -32,7 +32,8 @@ end_08_scripts_with = [
spacing = "\t"
class RomStr(str):
- """ Simple wrapper to prevent a giant rom from being shown on screen.
+ """
+ Simple wrapper to prevent a giant rom from being shown on screen.
"""
def __init__(self, *args, **kwargs):
@@ -41,13 +42,15 @@ class RomStr(str):
str.__init__(self)
def __repr__(self):
- """ Simplifies this object so that the output doesn't overflow stdout.
+ """
+ Simplifies this object so that the output doesn't overflow stdout.
"""
return "RomStr(too long)"
@classmethod
def load(cls, filename=None, crystal=True, red=False):
- """ Loads a ROM into a RomStr.
+ """
+ Loads a ROM into a RomStr.
"""
if crystal and not red and not filename:
file_handler = open("../baserom.gbc", "r")
@@ -62,8 +65,9 @@ class RomStr(str):
return RomStr(bytes)
def load_labels(self, filename="labels.json"):
- """ Loads labels from labels.json, or parses the source code file and
- generates new labels.
+ """
+ Loads labels from labels.json, or parses the source code file and
+ generates new labels.
"""
filename = os.path.join(os.path.dirname(__file__), filename)
@@ -109,7 +113,8 @@ class RomStr(str):
self.labels = json.read(open(filename, "r").read())
def get_address_for(self, label):
- """ Returns the address of a label. This is slow and could be improved
+ """
+ Returns the address of a label. This is slow and could be improved
dramatically.
"""
label = str(label)
@@ -119,18 +124,20 @@ class RomStr(str):
return None
def length(self):
- """ len(self)
+ """
+ len(self)
"""
return len(self)
def len(self):
- """ len(self)
+ """
+ len(self)
"""
return self.length()
def interval(self, offset, length, strings=True, debug=True):
- """ returns hex values for the rom starting at offset until
- offset+length
+ """
+ returns hex values for the rom starting at offset until offset+length
"""
returnable = []
for byte in self[offset:offset+length]:
@@ -141,16 +148,17 @@ class RomStr(str):
return returnable
def until(self, offset, byte, strings=True, debug=False):
- """ Returns hex values from rom starting at offset until the given
- byte.
+ """
+ Returns hex values from rom starting at offset until the given byte.
"""
return self.interval(offset, self.find(chr(byte), offset) - offset, strings=strings)
def to_asm(self, address, end_address=None, size=None, max_size=0x4000, debug=None):
- """ Disassembles ASM at some address. This will stop disassembling when
- either the end_address or size is met. Also, there's a maximum size
- that will be parsed, so that large patches of data aren't parsed as
- code.
+ """
+ Disassembles ASM at some address. This will stop disassembling when
+ either the end_address or size is met. Also, there's a maximum size
+ that will be parsed, so that large patches of data aren't parsed as
+ code.
"""
if type(address) in [str, unicode] and "0x" in address:
address = int(address, 16)
@@ -185,16 +193,19 @@ class RomStr(str):
#return DisAsm(start_address=start_address, end_address=end_address, size=size, max_size=max_size, debug=debug, rom=self)
class AsmList(list):
- """ Simple wrapper to prevent all asm lines from being shown on screen.
+ """
+ Simple wrapper to prevent all asm lines from being shown on screen.
"""
def length(self):
- """ len(self)
+ """
+ len(self)
"""
return len(self)
def __repr__(self):
- """ Simplifies this object so that the output doesn't overflow stdout.
+ """
+ Simplifies this object so that the output doesn't overflow stdout.
"""
return "AsmList(too long)"