Skip to content

Commit

Permalink
Added usage samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
achapkowski committed Aug 28, 2015
1 parent a4a58aa commit 77caf57
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
11 changes: 11 additions & 0 deletions samples/dataset_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Hermes allows users to return a standard set of information about a given
dataset. This example shows how to get the dataset properties.
"""
import hermes
import os

if __name__ == "__main__":
fc = r"c:\temp\scratch.gdb\somedataset"
metadata = hermes.Paperwork(dataset=fc)
print metadata.datasetProperties
23 changes: 23 additions & 0 deletions samples/metadata_edit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
This sample shows how to use Hermes to edit metadata
"""
import hermes
import os


if __name__ == "__main__":
fc = r"c:\temp\scratch.gdb\sampledata"
# Access the item's metadata
#
metadata = hermes.Paperwork(dataset=fc)
# convert the XML to a dictionary
#
data = metadata.convert()
# Make some generic changes
#
data['metadata']['idinfo']['descript']['abstract'] = "Hermes Was Here - changed an abstract"
data['metadata']['idinfo']['descript']['purpose'] = "Hermes Was Here - changed purpose"
# Save the changes back into the metadata
#
metadata.save(d=data)
del metadata
23 changes: 23 additions & 0 deletions samples/metadata_edit_published_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Hermes allows users to update and edit published services on ArcGIS Server
This example will show how users can import data from the local shapefile
to the service.
"""

import hermes
import os

if __name__ == "__main__":
service = r"GIS Servers\agsconnection\Hosted\USStatesBlue.MapServer"
sourceFC = r"c:\temp\states.shp"
# Access each dataset's metadata
#
serviceMD = hermes.Paperwork(dataset=service)
fcMD = hermes.Paperwork(dataset=sourceFC)
# Convert the local FC to the dictionary
localMetadata = fcMD.convert()
# Load the local FC metadata into the Hosted Feature Service
serviceMD.save(d=localMetadata)
del serviceMD
del fcMD
del localMetadata
23 changes: 23 additions & 0 deletions samples/metadata_walker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
This sample shows how users can walk a metadata structure to find the
information they need quickly. This sample shows only the XPath to each
item in the metadata and prints it out to the screen.
"""
import hermes
import os

def listKeyValues(d, path=""):
""" simple recursive print function to walk the metadata structure"""
for k,v in d.iteritems():
if path != "":
path += "/%s" % k
else:
path = k
print "Key - %s" % path
if isinstance(v, dict):
listKeyValues(v, path)
if __name__ == "__main__":
arcpy.env.workspace = r"c:\temp\scratch.gdb"
for fc in arcpy.ListFeatureClasses():
data = hermes.Paperwork(dataset=os.path.join(arcpy.env.workspace, fc)).convert()
listKeyValues(data)

0 comments on commit 77caf57

Please sign in to comment.