def handle_args(pwb_py, *args):
    """Handle args and get filename.

    @return: filename, script args, local args for pwb.py
    @rtype: tuple
    """
    fname = None
    index = 0
    for arg in args:
        if arg.startswith('-'):
            index += 1
        else:
            fname = arg
            if not fname.endswith('.py'):
                fname += '.py'
            break
    return fname, list(args[index + int(bool(fname)):]), args[:index]