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


Python paths.Paths类代码示例

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


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

示例1: multiselect

    def multiselect(cls, parent=None):
        default_dir = FSGSDirectories.get_floppies_dir()
        dialog = LauncherFilePicker(
            parent, gettext("Select Multiple Floppies"),
            "floppy", multiple=True)
        if not dialog.show_modal():
            return
        original_paths = dialog.get_paths()
        original_paths.sort()
        paths = []
        for path in original_paths:
            path = Paths.get_real_case(path)
            embedded_files = []
            if path.endswith(".zip"):
                archive = Archive(path)
                files = archive.list_files()
                for file in files:
                    name, ext = os.path.splitext(file)
                    # FIXME: get list of floppy extensions from a central
                    # place
                    if ext in [".adf", ".ipf"]:
                        embedded_files.append(file)
            if len(embedded_files) > 0:
                embedded_files.sort()
                print("found embedded floppy images:")
                print(embedded_files)
                for file in embedded_files:
                    paths.append(file)
            else:
                paths.append(path)

        checksum_tool = ChecksumTool(parent)
        for i, path in enumerate(paths):
            sha1 = checksum_tool.checksum(path)
            path = Paths.contract_path(
                path, default_dir, force_real_case=False)

            if i < 4:
                LauncherConfig.set_multiple([
                    ("floppy_drive_{0}".format(i), path),
                    ("x_floppy_drive_{0}_sha1".format(i), sha1)])
            LauncherConfig.set_multiple([
                ("floppy_image_{0}".format(i), path),
                ("x_floppy_image_{0}_sha1".format(i), sha1)])

        # blank the rest of the drives
        for i in range(len(paths), 4):
            LauncherConfig.set_multiple([
                ("floppy_drive_{0}".format(i), ""),
                ("x_floppy_drive_{0}_sha1".format(i), "")])
        # blank the rest of the image list
        for i in range(len(paths), 20):
            LauncherConfig.set_multiple([
                ("floppy_image_{0}".format(i), ""),
                ("x_floppy_image_{0}_sha1".format(i), "")])
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:55,代码来源:floppy_manager.py

示例2: get_whdload_dir

 def get_whdload_dir(cls):
     cls._initialize()
     path = os.path.join(cls.get_hard_drives_dir(), "WHDLoad")
     if os.path.exists(path):
         path = Paths.get_real_case(path)
         return path
     return None
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:7,代码来源:FSGSDirectories.py

示例3: unpack_game_hard_drive

    def unpack_game_hard_drive(self, drive_index, src):
        print("unpack_game_hard_drive", drive_index, src)
        scheme, dummy, dummy, game_uuid, drive = src.split("/")
        drive_prefix = drive + "/"
        dir_name = "DH{0}".format(drive_index)
        dir_path = os.path.join(self.temp_dir, dir_name)
        file_list = self.get_file_list_for_game_uuid(game_uuid)
        for file_entry in file_list:
            if self.stop_flag:
                return

            name = file_entry["name"]
            if not name.startswith(drive_prefix):
                continue

            # extract Amiga relative path and convert each path component
            # to host file name (where needed).

            amiga_rel_path = name[len(drive_prefix):]
            print("amiga_rel_path", amiga_rel_path)
            amiga_rel_parts = amiga_rel_path.split("/")
            for i, part in enumerate(amiga_rel_parts):
                # part can be blank if amiga_rel_parts is a directory
                # (ending with /)
                if part:
                    amiga_rel_parts[i] = amiga_filename_to_host_filename(part)
            amiga_rel_path = "/".join(amiga_rel_parts)

            dst_file = os.path.join(dir_path, amiga_rel_path)
            print(repr(dst_file))
            if name.endswith("/"):
                os.makedirs(Paths.str(dst_file))
                continue
            if not os.path.exists(os.path.dirname(dst_file)):
                os.makedirs(os.path.dirname(dst_file))
            sha1 = file_entry["sha1"]

            # current_task.set_progress(os.path.basename(dst_file))
            current_task.set_progress(amiga_rel_path)
            self.fsgs.file.copy_game_file("sha1://{0}".format(sha1), dst_file)

            # src_file = self.fsgs.file.find_by_sha1(sha1)
            # if not os.path.exists(os.path.dirname(dst_file)):
            #     os.makedirs(os.path.dirname(dst_file))
            # stream = self.fsgs.file.open(src_file)
            # # archive = Archive(src_file)
            # # f = archive.open(src_file)
            # data = stream.read()
            # assert hashlib.sha1(data).hexdigest() == sha1
            # with open(dst_file, "wb") as out_file:
            #     out_file.write(data)

            metadata = ["----rwed", " ", "2000-01-01 00:00:00.00", " ", "",
                        "\n"]
            if "comment" in file_entry:
                metadata[4] = self.encode_file_comment(file_entry["comment"])
            with open(dst_file + ".uaem", "wb") as out_file:
                out_file.write("".join(metadata).encode("UTF-8"))
            
        self.config["hard_drive_{0}".format(drive_index)] = dir_path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:60,代码来源:LaunchHandler.py

示例4: on_add_button

    def on_add_button(self):
        existing_items = self.create_list()

        default_dir = FSGSDirectories.get_floppies_dir()
        if self.cd_mode:
            dialog = LauncherFilePicker(
                self.get_window(), gettext("Select Multiple CD-ROMs"),
                "cd", multiple=True)
        else:
            dialog = LauncherFilePicker(
                self.get_window(), gettext("Select Multiple Floppies"),
                "floppy", multiple=True)
        if not dialog.show_modal():
            print("dialog.show returned false")
            return
        print("dialog.show returned true")
        paths = dialog.get_paths()
        paths.sort()
        print(paths)

        checksum_tool = ChecksumTool(self.get_window())
        for i, path in enumerate(paths):
            sha1 = checksum_tool.checksum(path)
            path = Paths.contract_path(path, default_dir)

            dir, file = os.path.split(path)
            if os.path.normcase(os.path.normpath(dir)) == \
                    os.path.normcase(os.path.normpath(default_dir)):
                path = file

            existing_items.append((path, sha1))
        self.set_new_config(existing_items)
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:32,代码来源:MediaListGroup.py

示例5: config_startup_scan

    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:,项目名称:,代码行数:59,代码来源:

示例6: get_hard_drives_dir

 def get_hard_drives_dir(cls):
     path = cls.portable_dir("hard_drives_dir")
     if not path:
         path = os.path.join(cls.get_base_dir(), "Hard Drives")
     if not os.path.exists(path):
         os.makedirs(path)
     path = Paths.get_real_case(path)
     return path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:FSGSDirectories.py

示例7: get_controllers_dir

 def get_controllers_dir(cls):
     path = cls.portable_dir("controllers_dir")
     if not path:
         path = os.path.join(cls.get_base_dir(), "Controllers")
     if not os.path.exists(path):
         os.makedirs(path)
     path = Paths.get_real_case(path)
     return path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:FSGSDirectories.py

示例8: get_kickstarts_dir

 def get_kickstarts_dir(cls):
     path = cls.portable_dir("kickstarts_dir")
     if not path:
         path = os.path.join(cls.get_base_dir(), "Kickstarts")
     if not os.path.exists(path):
         os.makedirs(path)
     path = Paths.get_real_case(path)
     return path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:FSGSDirectories.py

示例9: insert_floppy

 def insert_floppy(self, drive, path, sha1=None):
     if sha1 is None:
         sha1 = ChecksumTool().checksum(path)
     default_dir = FSGSDirectories.get_floppies_dir()
     path = Paths.contract_path(path, default_dir)
     self.set_config([
         ("floppy_drive_{0}".format(drive), path),
         ("x_floppy_drive_{0}_sha1".format(drive), sha1)])
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:AmigaContext.py

示例10: get_data_dir

 def get_data_dir(cls):
     path = cls.portable_dir("data_dir")
     if not path:
         path = os.path.join(cls.get_base_dir(), "Data")
     if not os.path.exists(path):
         os.makedirs(path)
     path = Paths.get_real_case(path)
     return path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:FSGSDirectories.py

示例11: get_save_states_dir

 def get_save_states_dir(cls):
     path = cls.portable_dir("save_states_dir")
     if not path:
         path = os.path.join(cls.get_base_dir(), "Save States")
     if not os.path.exists(path):
         os.makedirs(path)
     path = Paths.get_real_case(path)
     return path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:FSGSDirectories.py

示例12: get_floppies_dir

 def get_floppies_dir(cls):
     path = cls.portable_dir("floppies_dir")
     if not path:
         path = os.path.join(cls.get_base_dir(), "Floppies")
     if not os.path.exists(path):
         os.makedirs(path)
     path = Paths.get_real_case(path)
     return path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:FSGSDirectories.py

示例13: get_logs_dir

 def get_logs_dir(cls):
     path = cls.portable_dir("logs_dir")
     if not path:
         path = os.path.join(cls.get_cache_dir(), "Logs")
     if not os.path.exists(path):
         os.makedirs(path)
     path = Paths.get_real_case(path)
     return path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:FSGSDirectories.py

示例14: downloads_dir

 def downloads_dir(cls):
     path = cls.portable_dir("downloads_dir")
     if not path:
         path = os.path.join(cls.get_base_dir(), "Downloads")
     if not os.path.exists(path):
         os.makedirs(path)
     path = Paths.get_real_case(path)
     return path
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:FSGSDirectories.py

示例15: insert_multiple_floppies

    def insert_multiple_floppies(self, insert_paths):
        paths = []
        for path in insert_paths:
            embedded_files = []
            if path.endswith(".zip"):
                archive = Archive(path)
                files = archive.list_files()
                for file in files:
                    name, ext = os.path.splitext(file)
                    # FIXME: get list of floppy extensions from a central
                    # place
                    if ext in [".adf", ".ipf"]:
                        embedded_files.append(file)
            if len(embedded_files) > 0:
                embedded_files.sort()
                print("found embedded floppy images:")
                print(embedded_files)
                for file in embedded_files:
                    paths.append(file)
            else:
                paths.append(path)

        default_dir = FSGSDirectories.get_floppies_dir()
        checksum_tool = ChecksumTool()
        for i, path in enumerate(paths):
            sha1 = checksum_tool.checksum(path)
            path = Paths.contract_path(path, default_dir)

            if i < 4:
                self.set_config(
                    [
                        ("floppy_drive_{0}".format(i), path),
                        ("x_floppy_drive_{0}_sha1".format(i), sha1),
                    ]
                )
            self.set_config(
                [
                    ("floppy_image_{0}".format(i), path),
                    ("x_floppy_image_{0}_sha1".format(i), sha1),
                ]
            )

        # blank the rest of the drives
        for i in range(len(paths), 4):
            self.set_config(
                [
                    ("floppy_drive_{0}".format(i), ""),
                    ("x_floppy_drive_{0}_sha1".format(i), ""),
                ]
            )
        # blank the rest of the image list
        for i in range(len(paths), 20):
            self.set_config(
                [
                    ("floppy_image_{0}".format(i), ""),
                    ("x_floppy_image_{0}_sha1".format(i), ""),
                ]
            )
开发者ID:FrodeSolheim,项目名称:fs-uae-launcher,代码行数:58,代码来源:amigacontext.py


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