Generate JSON during build time.
[naja.git] / tools / gen_json.py
index 6ae4b514c3302f29d4dddedc728153b355954193..bec7ffc2b1228627e02912ad8b00cdb3cb153ee2 100755 (executable)
@@ -3,10 +3,8 @@
 import json
 import os
 
-import yaml
 
-
-def main():
+def main(update=True):
     data = os.path.join(os.path.dirname(__file__), '..', 'data')
     deck_dir = os.path.join(data, 'location_decks')
 
@@ -19,6 +17,10 @@ def main():
         yaml_path = os.path.join(deck_dir, yaml_fn)
         json_path = os.path.join(deck_dir, json_fn)
 
+        if not update and os.path.exists(json_path):
+            continue
+
+        import yaml
         with open(yaml_path) as yaml_f:
             obj = yaml.safe_load(yaml_f)
         with open(json_path, 'w') as json_f: