def __iter__(self):
        """Iterator over all the resources in capability order.

        Deals with the case of unknown capabilities or duplicate entries
        by using uri order for duplicates and adding any unknown ones
        at the end
        """
        self._iter_next_list = []
        # look through all resources and build capability to uri index
        uris = {}
        for uri in self.keys():
            cap = self[uri].capability
            if (cap not in uris):
                uris[cap] = []
            uris[cap].append(uri)
        # build list or uris in defined order for iterator
        for cap in self.order:
            if (cap in uris):
                for uri in sorted(uris[cap]):
                    self._iter_next_list.append(uri)
                del uris[cap]
        # add any left over capabilities we don't know about in alphabetical
        # order
        for cap in uris:
            for uri in sorted(uris[cap]):
                self._iter_next_list.append(uri)
        self._iter_next_list.reverse()
        return(iter(self._iter_next, None))
def __iter__ ( self ) : self . _iter_next_list = [ ] uris = { } for uri in self . keys ( ) : cap = self [ uri ] . capability if ( cap not in uris ) : uris [ cap ] = [ ] uris [ cap ] . append ( uri ) for cap in self . order : if ( cap in uris ) : for uri in sorted ( uris [ cap ] ) : self . _iter_next_list . append ( uri ) del uris [ cap ] for cap in uris : for uri in sorted ( uris [ cap ] ) : self . _iter_next_list . append ( uri ) self . _iter_next_list . reverse ( ) return ( iter ( self . _iter_next , None ) )
Iterator over all the resources in capability order.

        Deals with the case of unknown capabilities or duplicate entries
        by using uri order for duplicates and adding any unknown ones
        at the end