Development notes
-----------------
+Ensure the JSON is generated from the YAML, for people with out pyyaml::
+
+ ./tools/gen_json.py
+
Creating a source distribution with::
./scripts/build_unix.sh
The current game state.
"""
-import yaml
+try:
+ import yaml
+except ImportError:
+ yaml = None
+ import json
from naja.gameboard import GameBoard
from naja.resources import resources
def load_location_deck(name):
- with resources.get_file('location_decks', '%s.yaml' % (name,)) as deck_fp:
- return yaml.safe_load(deck_fp)
+ if yaml:
+ with resources.get_file('location_decks', '%s.yaml' % name) as deck_fp:
+ return yaml.safe_load(deck_fp)
+ else:
+ with resources.get_file('location_decks', '%s.json' % name) as deck_fp:
+ return json.load(deck_fp)
class GameState(object):
'logging', 'encodings', 'naja',
],
'includes': [
- 'pygame', 'yaml'
+ 'pygame',
],
'excludes': [
'numpy', 'pygame.sdlmain_osx', 'winreg', 'AppKit', 'Foundation',
--- /dev/null
+#!/usr/bin/env python
+
+import json
+import os
+
+import yaml
+
+
+def main():
+ data = os.path.join(os.path.dirname(__file__), '..', 'data')
+ deck_dir = os.path.join(data, 'location_decks')
+
+ for yaml_fn in os.listdir(deck_dir):
+ basename, extension = os.path.splitext(yaml_fn)
+ if extension != '.yaml':
+ continue
+ json_fn = basename + '.json'
+
+ yaml_path = os.path.join(deck_dir, yaml_fn)
+ json_path = os.path.join(deck_dir, json_fn)
+
+ with open(yaml_path) as yaml_f:
+ obj = yaml.safe_load(yaml_f)
+ with open(json_path, 'w') as json_f:
+ json.dump(obj, json_f, indent=2)
+
+
+if __name__ == '__main__':
+ main()