Created
February 19, 2012 17:21
Revisions
-
cassiel revised this gist
Feb 19, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,6 @@ def __unpack(self, x): if isinstance(x, Map): return Manifest(x) elif isinstance(x, List): return map(self.__unpack, x) else: return x -
cassiel revised this gist
Feb 19, 2012 . 1 changed file with 10 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,20 @@ 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(lambda i: self.__unpack(i), x) else: return x -
cassiel created this gist
Feb 19, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ from java.util import Map class Manifest: def __init__(self, h=None, **kw): self.keys = [] self.all = [] for k in kw: self.associate(k, kw[k]) if h is not None: for k in h.iterator(): n = k.getKey().getName() v = k.getValue() if isinstance(v, Map): self.associate(n, Manifest(v)) else: self.associate(n, v) def associate(self, key, val): setattr(self, key, val) self.keys.append(key) self.all.append(val)