forked from Esri/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4a58aa
commit 77caf57
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
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 |
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
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 |
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
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) |