Interactive interface for browsing global, full-resolution satellite imagery
generate categoryGroupOrder if not present
Jason Kente8794269a870
diff --git a/tasks/buildOptions.sh b/tasks/buildOptions.shindex 4bec0e7cc..ba4232a7a 100755--- a/tasks/buildOptions.sh+++ b/tasks/buildOptions.sh@@ -124,7 +124,9 @@ fi# Throw error if no categoryGroupOrder.json file presentif [ ! -e "$BUILD_DIR/config/wv.json/categoryGroupOrder.json" ] ; then- die "config/wv.json/categoryGroupOrder.json does not exist"+ echo "categoryGroupOrder.json not found. Generating..."+ "$PYTHON_SCRIPTS_DIR/generateCategoryGroupOrder.py" "$SRC_DIR/common/config/wv.json/categories/" \+ "$SRC_DIR/common/config/wv.json/"fi# Run mergeConfig.py on all directories in /configdiff --git a/tasks/python3/generateCategoryGroupOrder.py b/tasks/python3/generateCategoryGroupOrder.pynew file mode 100755index 000000000..21bde7f95--- /dev/null+++ b/tasks/python3/generateCategoryGroupOrder.py@@ -0,0 +1,31 @@+#!/usr/bin/env python++from optparse import OptionParser+import os+import json+import sys++prog = os.path.basename(__file__)+parser = OptionParser(usage="Usage: %s <input_dir> <output_dir>" % prog)+(options, args) = parser.parse_args()++category_directory = args[0]+output_dir = args[1]++category_dict = {}++for root, dirs, files in os.walk(category_directory):+ for file in files:+ file_path = os.path.join(root, file)+ with open(file_path) as category_config:+ config = json.load(category_config)+ try:+ category = list(config['categories'])[0]+ category_dict[category] = True+ except Exception as e:+ print("%s ERROR: Could not read category config. Check formatting of: %s" % (prog, file))+ sys.exit(1)++with open(output_dir + '/categoryGroupOrder.json', "w") as fp:+ json.dump({ 'categoryGroupOrder': list(category_dict) }, fp, indent=2, sort_keys=True)+ print("%s Successfully generated categoryGroupOrder.json with these categories: %s" % (prog, list(category_dict)))\ No newline at end of file