diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-09-02 13:25:49 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-09-02 13:25:49 -0500 |
commit | 37441a35b13f3421ba0c0f234e2ee4bbc5db4b63 (patch) | |
tree | 031d3acdf3c2a35e2f7ebbd0ad25dd1c830724f8 /pokemontools/labels.py | |
parent | 5b02c020f4784ba570f7da73a9835f5e984b8a90 (diff) |
make gbz80disasm use configuration
gbz80disasm now uses configuration to determine which files to load
before disassembling a chunk of bytes.
Diffstat (limited to 'pokemontools/labels.py')
-rw-r--r-- | pokemontools/labels.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pokemontools/labels.py b/pokemontools/labels.py index ca411d1..2e50b89 100644 --- a/pokemontools/labels.py +++ b/pokemontools/labels.py @@ -3,7 +3,37 @@ Various label/line-related functions. """ +import os +import json + import pointers +import crystal + +class Labels(object): + """ + Store all labels. + """ + filename = "labels.json" + + def __init__(self, config): + """ + Setup the instance. + """ + self.config = config + self.path = os.path.join(self.config.path, Labels.filename) + + def initialize(self): + """ + Handle anything requiring file-loading and such. + """ + if not os.path.exists(self.path): + logging.info( + "Running crystal.scan_for_predefined_labels to create \"{0}\". Trying.." + .format(Labels.filename) + ) + crystal.scan_for_predefined_labels() + + self.labels = json.read(open(self.path, "r").read()) def remove_quoted_text(line): """get rid of content inside quotes |