(self, txt)
return ret[0]
Returns the next completion for txt, or None if there is no completion.
Returns the next completion for txt, or None if there is no completion.
Returns the next completion for txt or None if there is no completion .
def complete(self, txt):
        """
            Returns the next completion for txt, or None if there is no completion.
        """
        path = os.path.expanduser(txt)
        if not self.lookup:
            if not self._testing:
                # Lookup is a set of (display value, actual value) tuples.
                self.lookup = []
                if os.path.isdir(path):
                    files = glob.glob(os.path.join(path, "*"))
                    prefix = txt
                else:
                    files = glob.glob(path+"*")
                    prefix = os.path.dirname(txt)
                prefix = prefix or "./"
                for f in files:
                    display = os.path.join(prefix, os.path.basename(f))
                    if os.path.isdir(f):
                        display += "/"
                    self.lookup.append((display, f))
            if not self.lookup:
                self.final = path
                return path
            self.lookup.sort()
            self.offset = -1
            self.lookup.append((txt, txt))
        self.offset += 1
        if self.offset >= len(self.lookup):
            self.offset = 0
        ret = self.lookup[self.offset]
        self.final = ret[1]
        return ret[0]
def complete ( self , txt ) : path = os . path . expanduser ( txt ) if not self . lookup : if not self . _testing : # Lookup is a set of (display value, actual value) tuples. self . lookup = [ ] if os . path . isdir ( path ) : files = glob . glob ( os . path . join ( path , "*" ) ) prefix = txt else : files = glob . glob ( path + "*" ) prefix = os . path . dirname ( txt ) prefix = prefix or "./" for f in files : display = os . path . join ( prefix , os . path . basename ( f ) ) if os . path . isdir ( f ) : display += "/" self . lookup . append ( ( display , f ) ) if not self . lookup : self . final = path return path self . lookup . sort ( ) self . offset = - 1 self . lookup . append ( ( txt , txt ) ) self . offset += 1 if self . offset >= len ( self . lookup ) : self . offset = 0 ret = self . lookup [ self . offset ] self . final = ret [ 1 ] return ret [ 0 ]