当前位置: 首页>>代码示例>>Python>>正文


Python LauncherConfig.load_file方法代码示例

本文整理汇总了Python中launcher.launcher_config.LauncherConfig.load_file方法的典型用法代码示例。如果您正苦于以下问题:Python LauncherConfig.load_file方法的具体用法?Python LauncherConfig.load_file怎么用?Python LauncherConfig.load_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在launcher.launcher_config.LauncherConfig的用法示例。


在下文中一共展示了LauncherConfig.load_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_settings

# 需要导入模块: from launcher.launcher_config import LauncherConfig [as 别名]
# 或者: from launcher.launcher_config.LauncherConfig import load_file [as 别名]
    def load_settings(cls):
        if cls.settings_loaded:
            return
        cls.settings_loaded = True

        settings = Settings.instance()
        settings.load()
        path = settings.path
        # path = app.get_settings_path()
        print("loading last config from " + repr(path))
        if not os.path.exists(path):
            print("settings file does not exist")
        # noinspection PyArgumentList
        cp = ConfigParser(interpolation=None)
        try:
            cp.read([path])
        except Exception as e:
            print(repr(e))
            return

        for key in LauncherSettings.old_keys:
            if app.settings.get(key):
                print("[SETTINGS] Removing old key", key)
                app.settings.set(key, "")

        if fsgs.config.add_from_argv():
            print("[CONFIG] Configuration specified via command line")
            # Prevent the launcher from loading the last used game
            LauncherSettings.set("parent_uuid", "")
        elif LauncherSettings.get("config_path"):
            if LauncherConfig.load_file(LauncherSettings.get("config_path")):
                print("[CONFIG] Loaded last configuration file")
            else:
                print("[CONFIG] Failed to load last configuration file")
                LauncherConfig.load_default_config()
        else:
            pass
            # config = {}
            # try:
            #     keys = cp.options("config")
            # except NoSectionError:
            #     keys = []
            # for key in keys:
            #     config[key] = fs.from_utf8_str(cp.get("config", key))
            # for key, value in config.items():
            #     print("loaded", key, value)
            #     fsgs.config.values[key] = value

        # Argument --new-config[=<platform>]
        new_config = "--new-config" in sys.argv
        new_config_platform = None
        for platform_id in PLATFORM_IDS:
            if "--new-config=" + platform_id in sys.argv:
                new_config = True
                new_config_platform = platform_id
        if new_config:
            LauncherConfig.load_default_config(platform=new_config_platform)
            # Prevent the launcher from loading the last used game
            LauncherSettings.set("parent_uuid", "")
开发者ID:,项目名称:,代码行数:61,代码来源:

示例2: load_settings

# 需要导入模块: from launcher.launcher_config import LauncherConfig [as 别名]
# 或者: from launcher.launcher_config.LauncherConfig import load_file [as 别名]
    def load_settings(cls):
        if cls.settings_loaded:
            return
        cls.settings_loaded = True

        settings = Settings.instance()
        settings.load()
        path = settings.path
        # path = app.get_settings_path()
        print("loading last config from " + repr(path))
        if not os.path.exists(path):
            print("settings file does not exist")
        # noinspection PyArgumentList
        cp = ConfigParser(interpolation=None)
        try:
            cp.read([path])
        except Exception as e:
            print(repr(e))
            return

        for key in LauncherSettings.old_keys:
            if app.settings.get(key):
                print("[SETTINGS] Removing old key", key)
                app.settings.set(key, "")

        if fsgs.config.add_from_argv():
            print("[CONFIG] Configuration specified via command line")
            # Prevent the launcher from loading the last used game
            LauncherSettings.set("parent_uuid", "")
        elif LauncherSettings.get("config_path"):
            if LauncherConfig.load_file(LauncherSettings.get("config_path")):
                print("[CONFIG] Loaded last configuration file")
            else:
                print("[CONFIG] Failed to load last configuration file")
                LauncherConfig.load_default_config()

            pass
开发者ID:glaubitz,项目名称:fs-uae-debian,代码行数:39,代码来源:fs_uae_launcher.py

示例3: run_config_or_game

# 需要导入模块: from launcher.launcher_config import LauncherConfig [as 别名]
# 或者: from launcher.launcher_config.LauncherConfig import load_file [as 别名]
    def run_config_or_game(cls):
        config_path = None
        archive_path = None
        floppy_image_paths = []
        cdrom_image_paths = []
        config_uuid = None
        floppy_exts = (".adf", ".ipf", ".dms", ".adz")
        cdrom_exts = (".cue", ".iso")
        archive_exts = (".zip", ".lha")

        # FIXME: replace argument "parsing" with use of argparse module
        # at some point

        last_arg = sys.argv[-1]
        file_ext = os.path.splitext(last_arg)[-1].lower()
        if file_ext == ".fs-uae":
            config_path = last_arg
        elif file_ext in archive_exts:
            archive_path = last_arg
        # elif file_ext in floppy_exts:
        #     floppy_image_paths = [last_arg]
        elif is_uuid(last_arg):
            config_uuid = last_arg.lower()
        for arg in sys.argv[1:]:
            if not arg.startswith("--"):
                _, ext = os.path.splitext(arg)
                if ext in floppy_exts:
                    floppy_image_paths.append(arg)
                elif ext in cdrom_exts:
                    cdrom_image_paths.append(arg)

        if config_path:
            print("config path given:", config_path)
            if not os.path.exists(config_path):
                print("config path does not exist", file=sys.stderr)
                return True
            LauncherConfig.load_file(config_path)
            fsgs.config.add_from_argv()
            return cls.run_config_directly()

        if archive_path:
            print("archive path given:", archive_path)
            if not os.path.exists(archive_path):
                print("archive path does not exist", file=sys.stderr)
                return True
            archive = Archive(os.path.realpath(archive_path))
            # We want to exclude pure directory entries when checking for
            # archives with only floppies.
            arc_files = [x for x in archive.list_files() if not x.endswith("/")]
            if all(map(lambda f: f.lower().endswith(floppy_exts), arc_files)):
                print("archive contains floppy disk images only")
                floppy_image_paths = arc_files
            else:
                values = HardDriveGroup.generate_config_for_archive(
                    archive_path)
                values["hard_drive_0"] = archive_path
                values.update(fsgs.config.config_from_argv())
                return cls.run_config_directly_with_values(values)

        if floppy_image_paths:
            enum_paths = tuple(enumerate(floppy_image_paths))
            values = {}
            values.update(fsgs.config.config_from_argv())
            max_drives = int(values.get("floppy_drive_count", "4"))
            values.update({"floppy_drive_{0}".format(k): v
                           for k, v in enum_paths[:max_drives]})
            values.update({"floppy_image_{0}".format(k): v
                           for k, v in enum_paths[:20]})
            return cls.run_config_directly_with_values(values)

        if cdrom_image_paths:
            enum_paths = tuple(enumerate(cdrom_image_paths))
            values = {"amiga_model": "CD32"}
            values.update(fsgs.config.config_from_argv())
            max_drives = int(values.get("cdrom_drive_count", "1"))
            values.update({"cdrom_drive_{0}".format(k): v
                           for k, v in enum_paths[:max_drives]})
            values.update({"cdrom_image_{0}".format(k): v
                           for k, v in enum_paths[:20]})
            return cls.run_config_directly_with_values(values)

        if config_uuid:
            print("config uuid given:", config_uuid)
            variant_uuid = config_uuid
            # values = fsgs.game.set_from_variant_uuid(variant_uuid)
            if fsgs.load_game_variant(variant_uuid):
                print("loaded variant")
            else:
                print("could not load variant, try to load game")
                game_uuid = config_uuid
                variant_uuid = fsgs.find_preferred_game_variant(game_uuid)
                print("preferred variant:", variant_uuid)
                fsgs.load_game_variant(variant_uuid)
            fsgs.config.add_from_argv()
            LauncherConfig.post_load_values(fsgs.config)
            return cls.run_config_directly()
开发者ID:glaubitz,项目名称:fs-uae-debian,代码行数:98,代码来源:fs_uae_launcher.py

示例4: run_config_or_game

# 需要导入模块: from launcher.launcher_config import LauncherConfig [as 别名]
# 或者: from launcher.launcher_config.LauncherConfig import load_file [as 别名]
    def run_config_or_game(cls):
        config_path = None
        archive_path = None
        floppy_image_paths = []
        cdrom_image_paths = []
        config_uuid = None
        floppy_extensions = (".adf", ".ipf", ".dms", ".adz")
        cdrom_extensions = (".cue", ".iso")
        archive_extensions = (".zip", ".lha")

        # FIXME: replace argument "parsing" with use of argparse module
        # at some point

        last_arg = sys.argv[-1]
        file_ext = os.path.splitext(last_arg)[-1].lower()
        if file_ext == ".fs-uae":
            config_path = last_arg
        elif file_ext in archive_extensions:
            archive_path = last_arg
        # elif file_ext in floppy_extensions:
        #     floppy_image_paths = [last_arg]
        elif is_uuid(last_arg):
            config_uuid = last_arg.lower()
        for arg in sys.argv[1:]:
            if not arg.startswith("--"):
                _, ext = os.path.splitext(arg)
                if ext in floppy_extensions:
                    floppy_image_paths.append(arg)
                elif ext in cdrom_extensions:
                    cdrom_image_paths.append(arg)

        if config_path:
            print("[STARTUP] Config path given:", config_path)
            if not os.path.exists(config_path):
                print("[STARTUP] Config path does not exist", file=sys.stderr)
                return True
            LauncherConfig.load_file(config_path)
            fsgs.config.add_from_argv()
            return cls.run_config_directly()

        if archive_path:
            print("[STARTUP] Archive path given:", archive_path)
            if not os.path.exists(archive_path):
                print("[STARTUP] Archive path does not exist", file=sys.stderr)
                return True
            archive = Archive(os.path.realpath(archive_path))
            archive_name = os.path.basename(archive_path)
            # We want to exclude pure directory entries when checking for
            # archives with only floppies.
            arc_files = [
                x for x in archive.list_files() if not x.endswith("/")
            ]
            if all(
                map(lambda f: f.lower().endswith(floppy_extensions), arc_files)
            ):
                print("[STARTUP] Archive contains floppy disk images only")
                floppy_image_paths = arc_files
            else:
                if cls.auto_detect_game:
                    # FIXME: Could also do this for floppy file archives.
                    archive_util = ArchiveUtil(archive_path)
                    archive_uuid = archive_util.create_variant_uuid()
                    print(
                        "[STARTUP] Try auto-detecting variant, uuid =",
                        archive_uuid,
                    )
                    if fsgs.load_game_variant(archive_uuid):
                        print("[STARTUP] Auto-detected variant", archive_uuid)
                        print("[STARTUP] Adding archive files to file index")
                        for archive_file in archive.list_files():
                            stream = archive.open(archive_file)
                            data = stream.read()
                            size = len(data)
                            sha1 = hashlib.sha1(data).hexdigest()
                            FileDatabase.add_static_file(
                                archive_file, size=size, sha1=sha1
                            )
                        fsgs.config.add_from_argv()
                        fsgs.config.set("__config_name", archive_name)
                        LauncherConfig.post_load_values(fsgs.config)
                        return cls.run_config_directly()

                values = whdload.generate_config_for_archive(archive_path)
                values["hard_drive_0"] = archive_path
                values.update(fsgs.config.config_from_argv())
                # archive_name, archive_ext = os.path.splitext(archive_name)
                values["__config_name"] = archive_name
                return cls.run_config_directly_with_values(values)

        if floppy_image_paths:
            enum_paths = tuple(enumerate(floppy_image_paths))
            values = {}
            values.update(fsgs.config.config_from_argv())
            max_drives = int(values.get("floppy_drive_count", "4"))
            values.update(
                {
                    "floppy_drive_{0}".format(k): v
                    for k, v in enum_paths[:max_drives]
                }
            )
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


注:本文中的launcher.launcher_config.LauncherConfig.load_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。