def complete_rule(rule, cmd):
 global rline_mpstate
 rule_components = rule.split(' ')
 if (len(cmd) == 0):
  return rule_expand(rule_components[0], '')
 for i in range((len(cmd) - 1)):
  if (not rule_match(rule_components[i], cmd[i])):
   return []
 expanded = rule_expand(rule_components[(len(cmd) - 1)], cmd[(-1)])
 return expanded

def complete_rule ( rule , cmd ) : global rline_mpstate rule_components = rule . split ( ' ' ) if ( len ( cmd ) == 0 ) : return rule_expand ( rule_components [ 0 ] , '' ) for i in range ( ( len ( cmd ) - 1 ) ) : if ( not rule_match ( rule_components [ i ] , cmd [ i ] ) ) : return [ ] expanded = rule_expand ( rule_components [ ( len ( cmd ) - 1 ) ] , cmd [ ( - 1 ) ] ) return expanded
complete using one rule .