diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-08-03 14:52:12 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-08-03 14:53:42 -0500 |
commit | 2bbe5da4b61aafb9c3b9855c709c3bf48d95ff18 (patch) | |
tree | 5cd2e1e812663b921d1acc9ed0289158ba68b858 /wram.py | |
parent | f17090f3197e90b8fad15bc99453450492201b8f (diff) |
ignore wram.asm non-existence
The IOError is now caught and swallowed by read_wram_sections.
Diffstat (limited to 'wram.py')
-rw-r--r-- | wram.py | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -54,8 +54,22 @@ def read_bss_sections(bss): sections.append(section) return sections -wram_sections = read_bss_sections(open(os.path.join(os.path.dirname(path), 'wram.asm'), 'r').readlines()) - +def read_wram_sections(): + """ + Opens the wram file and calls read_bss_sections. + """ + wram_content = None + wram_file_path = os.path.join(os.path.dirname(path), 'wram.asm') + try: + wram_file_handler = open(wram_file_path, 'r') + except IOError as exception: + wram_content = [""] + else: + wram_content = wram_file_handler.readlines() + wram_sections = read_bss_sections(wram_content) + return wram_sections + +wram_sections = read_wram_sections() def make_wram_labels(): wram_labels = {} @@ -68,7 +82,6 @@ def make_wram_labels(): wram_labels = make_wram_labels() - def constants_to_dict(constants): return dict((eval(constant[constant.find('EQU')+3:constant.find(';')].replace('$','0x')), constant[:constant.find('EQU')].strip()) for constant in constants) |