Esempio n. 1
0
 def __iter__(self):
     """ Iterates over item attributes. """
     attr = gv.firstattr(self.handle)
     while gv.ok(attr):
         yield gv.nameof(attr), \
             decode_page(gv.getv(self.handle, attr))
         attr = gv.nextattr(self.handle, attr)
Esempio n. 2
0
    def _iterattrs(self, handle=""):
        """ Iterate over the attributes of a graph item.

        If no handle attribute is given, iterates over the attributes
        of the root graph
        """
        if not handle:
            handle = self.handle
        attr = gv.firstattr(handle)
        while gv.ok(attr):
            yield gv.nameof(attr), decode_page(gv.getv(handle, attr))
            attr = gv.nextattr(handle, attr)
Esempio n. 3
0
    def __getattr__(self, name):
        """ Finds the named attribute, returns its value """
        handle = self.__dict__['handle']

        name = encode_page(name)

        retval = gv.getv(handle, gv.findattr(handle, name))
        # Needed mainly for dict() for work, getattribute excepts
        # and so __iter__ is called. Non-gv attrs are not returned.
        if not retval:
            object.__getattribute__(self, name)

        return decode_page(retval)