'Try to match a given keystring with any bound keychain.
Args:
cmd_input: The command string to find.
Return:
A tuple (matchtype, binding).
matchtype: Match.definitive, Match.ambiguous, Match.partial or
Match.none
binding: - None with Match.partial/Match.none
- The found binding with Match.definitive/
Match.ambiguous'

def _match_key(self, cmd_input):

    definitive_match = None
    partial_match = False
    try:
        definitive_match = (cmd_input, self.bindings[cmd_input])
    except KeyError:
        pass
    for binding in self.bindings:
        if ((definitive_match is not None) and (binding == definitive_match[0])):
            continue
        elif binding.startswith(cmd_input):
            partial_match = True
            break
    if ((definitive_match is not None) and partial_match):
        return (self.Match.ambiguous, definitive_match[1])
    elif (definitive_match is not None):
        return (self.Match.definitive, definitive_match[1])
    elif partial_match:
        return (self.Match.partial, None)
    else:
        return (self.Match.none, None)
