From 2bbe5da4b61aafb9c3b9855c709c3bf48d95ff18 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sat, 3 Aug 2013 14:52:12 -0500 Subject: ignore wram.asm non-existence The IOError is now caught and swallowed by read_wram_sections. --- wram.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'wram.py') diff --git a/wram.py b/wram.py index c5d30f2..5305afa 100644 --- a/wram.py +++ b/wram.py @@ -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) -- cgit v1.2.3