def get_script_info(script_path):
    """extract info from script, like basename, __author__, __title__ and __desc__."""
    script_path = os.path.normpath(script_path)
    script_name = os.path.basename(script_path)
    if script_path.endswith(".py"):
        pyfilepath = script_path
        parent_name = os.path.basename(os.path.dirname(script_path))
        if parent_name.endswith(EXT):
            script_name = parent_name
    else:
        pyfilename = script_name.replace(EXT, ".py")
        pyfilepath = os.path.join(script_path, pyfilename)

    if not os.path.exists(pyfilepath) and six.PY2:
        pyfilepath = pyfilepath.encode(sys.getfilesystemencoding())
    with open(pyfilepath, encoding="utf-8") as pyfile:
        pyfilecontent = pyfile.read()

    author, title, desc = get_author_title_desc(pyfilecontent)

    result_json = {"name": script_name, "path": script_path, "author": author, "title": title, "desc": desc}
    return json.dumps(result_json)
extract info from script, like basename, __author__, __title__ and __desc__.
airtest/cli/info.py