Monday, August 31, 2015

The Walking Metadata (hermes example)

The hermes Python package was released (v1) last week, and now I'm going to show how to read the values instead a given metadata file from a feature class.

import hermes
if __name__ == "__main__":
    fc = r"c:\data_and_maps\usa\census\blkgrp.sdc\blkgrp"
    paperwork = hermes.Paperwork(dataset=fc)
    data = paperwork.convert()
    for k,v in data.iteritems():
        print k, v

In this example, I access the dataset, in this case a feature class.  To convert the metadata to a dictionary, call the convert().  Then you can use the dictionary iterator object to walk the data.

This example is just going to show something like:

metadata {some dictionary value}


Enjoy!

Friday, August 28, 2015

Work with metadata check out hermes

So you have to work with metadata? Or you love paperwork, or you just hate using the Python XML packages? Give hermes a try. It is named after And inspired by Hermes Conrad from Futurama. It is a simple set of tools to translate the Xml to a Python dictionary. Check it out here: http://github.com/Esri/hermes Fork it, follow it, improve it. I'll be posting a couple of usage examples over the next few weeks. I look forward to everyone's feedback.

Monday, August 3, 2015

ArcREST (v3 beta) manageorg update

On the current master branch, the ArcREST team is up to some good old fashion reworking in the hopes of making life a bit easier when working with portal and AGOL.

In today's push (8/3/2015). The big update is the manageorg sub package is changed to make the user's content iterable.

Let's check out an example:

import arcrest
admin = arcrest.manageorg.Administration(url=url,
                                         securityHandler=sh)
user = admin.content.users.user("ARandomUserAccount")
for item in user.items:
    print item.id, item.access, item.owner, item.ownerFolder
    for k in item:
        print k
You'll notice two really interesting things. We are accessing a site with a token handler sh, then we use the for loop syntax to loop through all the items in the root folder. Also, the UserItem object, which is returned from the iterator off of user.items also returns Key/Value pairs from the raw JSON. This means you can get really find grained information from the object, not just what is stubbed out in the class objects. I would like some feedback on this. It was tons of code changes, and wanted to make sure I didn't drop any functions anyone really needed. Enjoy!