Skip to content

Instantly share code, notes, and snippets.

@cassiel
Created February 19, 2012 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cassiel/1864710 to your computer and use it in GitHub Desktop.
Save cassiel/1864710 to your computer and use it in GitHub Desktop.
from java.util import Map, List
class Manifest:
def __init__(self, h=None, **kw):
for k in kw:
setattr(self, k, kw[k])
if h is not None:
for k in h.iterator():
n = k.getKey().getName()
v = k.getValue()
setattr(self, n, self.__unpack(v))
def __unpack(self, x):
if isinstance(x, Map):
return Manifest(x)
elif isinstance(x, List):
return map(self.__unpack, x)
else:
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment