Puzzles now live in a subdir
authorStefano Rivera <stefano@rivera.za.net>
Sat, 17 May 2014 16:31:33 +0000 (18:31 +0200)
committerStefano Rivera <stefano@rivera.za.net>
Sat, 17 May 2014 16:31:54 +0000 (18:31 +0200)
.gitignore
tools/gen_json.py

index f7f4168673fee9ab2d64b1486f95141ac1b005fd..2e6f0cf0c9bbf840ccf779f662ea79fbdd1d7d03 100644 (file)
@@ -12,3 +12,4 @@ py2exe.log
 VE
 ve
 /data/location_decks/*.json
+/data/location_decks/puzzles/*.json
index bec7ffc2b1228627e02912ad8b00cdb3cb153ee2..e3468cd530ea1be35970a5e4670c907bb5c7ff33 100755 (executable)
@@ -6,16 +6,22 @@ import os
 
 def main(update=True):
     data = os.path.join(os.path.dirname(__file__), '..', 'data')
+
     deck_dir = os.path.join(data, 'location_decks')
+    convert_to_json(deck_dir, update)
+    puzzle_dir = os.path.join(deck_dir, 'puzzles')
+    convert_to_json(puzzle_dir, update)
+
 
-    for yaml_fn in os.listdir(deck_dir):
+def convert_to_json(directory, update=True):
+    for yaml_fn in os.listdir(directory):
         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)
+        yaml_path = os.path.join(directory, yaml_fn)
+        json_path = os.path.join(directory, json_fn)
 
         if not update and os.path.exists(json_path):
             continue