Ejemplo n.º 1
0
    def __findnode(self, key):
        if '/' in key:
            nodes = key.split('/')
            if key.startswith('/'):
                g = self.__findroot()
            else:
                g = self
            for n in nodes:
                if n == "..":
                    p = g._getparent()
                    if p is not None:
                        g = p
                    else:
                        raise KeyError, "No parent exists"
                elif n == "" or n == ".":
                    pass
                else:
#                    print n
#                    print(dir(g))
                    g = _ldict.__getitem__(g, n)
            return g

        if key == '..':
            p = self._getparent()
            if p is not None:
                return p
            else:
                raise KeyError, "No parent exists"
        elif key == '.':
            return self

        return _ldict.__getitem__(self, key)
Ejemplo n.º 2
0
    def __findnode(self, key):
        if '/' in key:
            nodes = key.split('/')
            if key.startswith('/'):
                g = self.__findroot()
            else:
                g = self
            for n in nodes:
                if n == "..":
                    p = g._getparent()
                    if p is not None:
                        g = p
                    else:
                        raise KeyError, "No parent exists"
                elif n == "" or n == ".":
                    pass
                else:
                    #                    print n
                    #                    print(dir(g))
                    g = _ldict.__getitem__(g, n)
            return g
        elif key == '..':
            p = self._getparent()
            if p is not None:
                return p
            else:
                raise KeyError, "No parent exists"
        elif key == '.':
            return self

        return _ldict.__getitem__(self, key)
Ejemplo n.º 3
0
    def __findnode(self, key):
        if '/' in key:
            nodes = key.split('/')
            if key.startswith('/'):
                g = self.__findroot()
            else:
                g = self
            for n in nodes:
                if n == "..":
                    p = g._getparent()
                    if p is not None:
                        g = p
                    else:
                        raise KeyError("No parent exists")
                elif n == "" or n == ".":
                    pass
                else:
                    try:
                        g = _ldict.__getitem__(g, n)
                    except: # attempt to use sanitised version
                        n = "_" + n
                        g = _ldict.__getitem__(g, n)
            return g
        elif key == '..':
            p = self._getparent()
            if p is not None:
                return p
            else:
                raise KeyError("No parent exists")
        elif key == '.':
            return self

        return _ldict.__getitem__(self, key)
Ejemplo n.º 4
0
    def __str__(self):
        s = ""
        for a in self.attrs:
            s += "   @%s = %s\n" % (a, self.attrs[a]) 

        for k in self:
            if not k in ["nxname", "attrs"] and not '__parent' in k:
                s += "    %s" % k
                if isinstance(_ldict.__getitem__(self, k), HDF5group):
                    s += "/\n"
                else:
                    s += "\n"
        if hasattr(self, "nxname"):
            return self.nxname + "\n" + s
        else:
            return s
Ejemplo n.º 5
0
    def __str__(self):
        s = ""
        for a in self.attrs:
            s += "   @%s = %s\n" % (a, self.attrs[a])

        for k in self:
            if not k in ["nxname", "attrs"] and not '__parent' in k:
                s += "    %s" % k
                if isinstance(_ldict.__getitem__(self, k), HDF5group):
                    s += "/\n"
                else:
                    s += "\n"
        if hasattr(self, "nxname"):
            return self.nxname + "\n" + s
        else:
            return s
Ejemplo n.º 6
0
 def __getitem__(self, key):
     from types import StringType
     if type(key) is StringType:
         return self.__findnode(key)
     return _ldict.__getitem__(self, key)
Ejemplo n.º 7
0
 def __init__(self, attrs={}, parent=None):
     _ldict.__init__(self)
     HDF5node.__init__(self, attrs, parent)
Ejemplo n.º 8
0
 def __getitem__(self, key):
     from types import StringType
     if type(key) is StringType:
         return self.__findnode(key)
     return _ldict.__getitem__(self, key)
Ejemplo n.º 9
0
 def __init__(self, attrs={}, parent=None):
     _ldict.__init__(self)
     HDF5node.__init__(self, attrs, parent)
Ejemplo n.º 10
0
 def __getitem__(self, key):
     if isinstance(key, str):
         return self.__findnode(key)
     return _ldict.__getitem__(self, key)