summaryrefslogtreecommitdiff
path: root/wram.py
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-08-03 15:05:17 -0500
committerBryan Bishop <kanzure@gmail.com>2013-08-03 15:05:17 -0500
commitb94bbf92bac341936f2778aecee32e6d1d05c170 (patch)
tree7f3e05eaa3c812d742f8783784c6dc66e19f16c1 /wram.py
parent1bdb15456e5a20a0cad7832e3202c90eee4beba0 (diff)
make read_hram_constants to eat hram.asm IOError
Diffstat (limited to 'wram.py')
-rw-r--r--wram.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/wram.py b/wram.py
index e380ca3..b74fa66 100644
--- a/wram.py
+++ b/wram.py
@@ -92,5 +92,19 @@ def scrape_constants(text):
text = text.split('\n')
return constants_to_dict([line for line in text if 'EQU' in line[:line.find(';')]])
-hram_constants = scrape_constants(open(os.path.join(os.path.dirname(path), 'hram.asm'),'r').readlines())
+def read_hram_constants():
+ """
+ Load constants from hram.asm.
+ """
+ try:
+ hram_file_handler = open(os.path.join(os.path.dirname(path), 'hram.asm'), 'r')
+ except IOError as exception:
+ hram_lines = [""]
+ else:
+ hram_lines = hram_file_handler.readlines()
+ hram_constants = scrape_constants(hram_lines)
+ return hram_constants
+
+hram_constants = read_hram_constants()
+
gbhw_constants = scrape_constants(open(os.path.join(os.path.dirname(path), 'gbhw.asm'),'r').readlines())