[IPython-dev] Completer in ipython 0.6.12

Frédéric Mantegazza mantegazza at ill.fr
Wed Mar 16 10:56:15 EST 2005

Hello Fernando,

A few months ago, with your help, I made a patch to add my own matcher, but 
it does not work anymore in the 0.6.12 version. Now, it does nothing when I 
hit the TAB key, in any case :o(

Here is the code used:

def proxy_matches(self, text, state):
    """ Get the attribute of a remove Pyro object.
    log = Logger('client')

    # Another option, seems to work great. Catches things like ''.<tab>
    m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)

    if not m:
        return []
    expr, attr = m.group(1, 3)
    matches = []
        object = eval(expr, self.namespace)
        if isinstance(object, Pyro.core.DynamicProxyWithAttrs):
            words = object.getAvailableAttributes()
            matches = []
            n = len(attr)
            if words:
                for word in words:
                    if word[:n] == attr and word != "__builtins__":
                        matches.append("%s.%s" % (expr, word))

    except NameError:
    except Pyro.errors.ConnectionClosedError:
        log.error("Connexion closed")
        object.adapter.rebindURI() # Should be moved to runcode()
        matches = [""]

    return matches

ipshell.IP.Completer.matchers.insert(0, 'proxy_matches')
IPython.iplib.MagicCompleter.proxy_matches = proxy_matches

I saw that you changed lot of things in the iplib.py file, and I don't know 
how to have my patch working. Could your explain me how things works, now ?

Thank's for your help,


More information about the IPython-dev mailing list