diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-09-04 20:38:11 -0700 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-09-04 20:38:11 -0700 |
commit | ee05e2fe1d03e0e68c64cea09ec41ab70e12bc3a (patch) | |
tree | db3b846aa6c92acd4cbf6f4bc0f7e5fb566ade27 /pokemontools/labels.py | |
parent | c2712bb90f09083f0bfa786750be2a9b34105fa9 (diff) | |
parent | 37441a35b13f3421ba0c0f234e2ee4bbc5db4b63 (diff) |
Merge pull request #10 from kanzure/config
Configuration for paths
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 |