Created
July 19, 2011 13:38
-
-
Save dwins/1092353 to your computer and use it in GitHub Desktop.
Upload a directory of SLDs
This file contains hidden or 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 geoserver.catalog | |
import os, os.path | |
cat = geoserver.catalog.Catalog( | |
'http://localhost:8080/geoserver/rest', | |
"admin", "geoserver") | |
style_dir = "/home/dwins/Downloads/graphite/" | |
suffix = 'graphite' | |
extant_styles = set(s.name for s in cat.get_styles()) | |
for style_file in os.listdir(style_dir): | |
base, ext = os.path.splitext(style_file) | |
name = '%s_%s' % (base, suffix) if suffix else base | |
if ext == '.sld': | |
overwrite = (name in extant_styles) | |
with open(os.path.join(style_dir, style_file)) as sld: | |
cat.create_style(name, sld.read(), overwrite) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment