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


Python Paths.join方法代码示例

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


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

示例1: config_startup_scan

# 需要导入模块: from fsbc.paths import Paths [as 别名]
# 或者: from fsbc.paths.Paths import join [as 别名]
    def config_startup_scan(cls):
        if cls._config_scanned:
            return
        cls._config_scanned = True

        configs_dir = FSGSDirectories.get_configurations_dir()
        print("config_startup_scan", configs_dir)
        print(LauncherSettings.settings)

        settings_mtime = LauncherSettings.get("configurations_dir_mtime")
        dir_mtime = cls.get_dir_mtime_str(configs_dir)
        if settings_mtime == dir_mtime + "+" + str(Database.VERSION):
            print("... mtime not changed", settings_mtime, dir_mtime)
            return

        database = Database.get_instance()
        file_database = FileDatabase.get_instance()

        print("... database.find_local_configurations")
        local_configs = Database.get_instance().find_local_configurations()
        print("... walk configs_dir")
        for dir_path, dir_names, file_names in os.walk(configs_dir):
            for file_name in file_names:
                if not file_name.endswith(".fs-uae"):
                    continue
                path = Paths.join(dir_path, file_name)
                if path in local_configs:
                    local_configs[path] = None
                    # already exists in database
                    continue
                name, ext = os.path.splitext(file_name)
                # search = ConfigurationScanner.create_configuration_search(
                # name)
                scanner = ConfigurationScanner()
                print("[startup] adding config", path)
                file_database.delete_file(path=path)
                with open(path, "rb") as f:
                    sha1 = hashlib.sha1(f.read()).hexdigest()
                file_database.add_file(path=path, sha1=sha1)

                game_id = database.add_configuration(
                    path=path, name=scanner.create_configuration_name(name)
                )
                database.update_game_search_terms(
                    game_id, scanner.create_search_terms(name)
                )

        for path, config_id in local_configs.items():
            if config_id is not None:
                print("[startup] removing configuration", path)
                database.delete_game(id=config_id)
                file_database.delete_file(path=path)
        print("... commit")
        database.commit()

        LauncherSettings.set(
            "configurations_dir_mtime",
            cls.get_dir_mtime_str(configs_dir) + "+" + str(Database.VERSION),
        )
开发者ID:,项目名称:,代码行数:61,代码来源:

示例2: scan_dir_for_kickstarts

# 需要导入模块: from fsbc.paths import Paths [as 别名]
# 或者: from fsbc.paths.Paths import join [as 别名]
 def scan_dir_for_kickstarts(scan_dir):
     file_database = FileDatabase.get_instance()
     for dir_path, dir_names, file_names in os.walk(scan_dir):
         for file_name in file_names:
             if not file_name.endswith(".rom"):
                 continue
             path = Paths.join(dir_path, file_name)
             if file_database.find_file(path=path):
                 continue
             print("[startup] adding kickstart", path)
             ROMManager.add_rom_to_database(path, file_database)
开发者ID:,项目名称:,代码行数:13,代码来源:

示例3: kickstart_startup_scan

# 需要导入模块: from fsbc.paths import Paths [as 别名]
# 或者: from fsbc.paths.Paths import join [as 别名]
    def kickstart_startup_scan(cls):
        if cls._kickstart_scanned:
            return
        cls._kickstart_scanned = True

        print("kickstart_startup_scan")
        kickstarts_dir = FSGSDirectories.get_kickstarts_dir()
        if LauncherSettings.get(
            "kickstarts_dir_mtime"
        ) == cls.get_dir_mtime_str(kickstarts_dir):
            print("... mtime not changed")
        else:
            file_database = FileDatabase.get_instance()
            print("... database.find_local_roms")
            local_roms = file_database.find_local_roms()
            print("... walk kickstarts_dir")
            for dir_path, dir_names, file_names in os.walk(kickstarts_dir):
                for file_name in file_names:
                    if not file_name.lower().endswith(
                        ".rom"
                    ) and not file_name.lower().endswith(".bin"):
                        continue
                    path = Paths.join(dir_path, file_name)
                    if path in local_roms:
                        local_roms[path] = None
                        # already exists in database
                        continue
                    print("[startup] adding kickstart", path)
                    ROMManager.add_rom_to_database(path, file_database)
            print(local_roms)
            for path, file_id in local_roms.items():
                if file_id is not None:
                    print("[startup] removing kickstart", path)
                    file_database.delete_file(id=file_id)
            print("... commit")
            file_database.commit()
            LauncherSettings.set(
                "kickstarts_dir_mtime", cls.get_dir_mtime_str(kickstarts_dir)
            )

        amiga = Amiga.get_model_config("A500")
        for sha1 in amiga["kickstarts"]:
            if fsgs.file.find_by_sha1(sha1=sha1):
                break
        else:
            file_database = FileDatabase.get_instance()
            cls.amiga_forever_kickstart_scan()
            file_database.commit()
开发者ID:,项目名称:,代码行数:50,代码来源:


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