def parse_command_path(path):
    # split url path into parts, lowercase, trim trailing slash, return tuple
    def path_parts(path):
        path = path.strip().lower()
        if len(path) < 1 or path[0] != '/':
            raise PathError(path)
        if path[-1] == '/':
            path = path[:-1]
        p = map(str.strip, path.split('/'))
        p = tuple(p[1:])
        return p

    p = path_parts(path)

    # for path = '/' return 'help' action
    if not p:
        return 'help', None

    action = p[0]
   
    if action.upper() in iptables.RULE_TARGETS:
        try:
            return action, build_rule(p)
        except __HOLE__, e:
            raise PathError(path, e.message)
    
    if action == 'list':
        if len(p) == 1:
            return action, None
        elif len(p) == 2:
            chain = p[1].upper()
            if chain in iptables.RULE_CHAINS:
                return action, chain
            else:
                raise PathError(path, 'Wrong chain name for list command')
        else:
            raise PathError(path, 'Too many details for the list command')
        
    raise PathError(path)


# From the path parts tuple build and return Rule for drop/accept/reject type of command
dataset/ETHPy150Open securitykiss-com/rfw/rfw/cmdparse.py/parse_command_path