Created
August 6, 2016 21:31
-
-
Save lukasmartinelli/36f62ce9d38a1431c797556a880733f2 to your computer and use it in GitHub Desktop.
Patch sources of a Mapbox GL style with settings from style and purge private details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sys | |
if __name__ == '__main__': | |
if len(sys.argv) >= 2: | |
style_src = sys.argv[1] | |
patch_src = sys.argv[2] | |
else: | |
print('patch_mabpox_gl_style.py <style> <patch-src>') | |
sys.exit(1) | |
with open(style_src) as style_fh: | |
with open(patch_src) as patch_fh: | |
style_doc = json.load(style_fh) | |
patch_doc = json.load(patch_fh) | |
style_doc["sources"] = patch_doc["sources"] | |
style_doc["sprite"] = patch_doc["sprite"] | |
style_doc["glyphs"] = patch_doc["glyphs"] | |
del style_doc["created"] | |
del style_doc["id"] | |
del style_doc["modified"] | |
del style_doc["owner"] | |
del style_doc["draft"] | |
print(json.dumps(style_doc, sort_keys=True, indent=4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment