當前位置: 首頁>>代碼示例>>Python>>正文


Python Paths.contract_path方法代碼示例

本文整理匯總了Python中fsbc.paths.Paths.contract_path方法的典型用法代碼示例。如果您正苦於以下問題:Python Paths.contract_path方法的具體用法?Python Paths.contract_path怎麽用?Python Paths.contract_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fsbc.paths.Paths的用法示例。


在下文中一共展示了Paths.contract_path方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_add_button

# 需要導入模塊: from fsbc.paths import Paths [as 別名]
# 或者: from fsbc.paths.Paths import contract_path [as 別名]
    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,代碼行數:34,代碼來源:MediaListGroup.py

示例2: insert_floppy

# 需要導入模塊: from fsbc.paths import Paths [as 別名]
# 或者: from fsbc.paths.Paths import contract_path [as 別名]
 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,代碼行數:10,代碼來源:AmigaContext.py

示例3: insert_multiple_floppies

# 需要導入模塊: from fsbc.paths import Paths [as 別名]
# 或者: from fsbc.paths.Paths import contract_path [as 別名]
    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,代碼行數:60,代碼來源:amigacontext.py

示例4: insert_cd

# 需要導入模塊: from fsbc.paths import Paths [as 別名]
# 或者: from fsbc.paths.Paths import contract_path [as 別名]
 def insert_cd(self, drive, path, sha1=None):
     if sha1 is None:
         sha1 = ""
         print("FIXME: not calculating CD checksum just yet")
     default_dir = FSGSDirectories.get_cdroms_dir()
     path = Paths.contract_path(path, default_dir)
     self.set_config([
         ("cdrom_drive_{0}".format(drive), path),
         ("x_cdrom_drive_{0}_sha1".format(drive), sha1)])
開發者ID:EdwardBetts,項目名稱:fs-uae-launcher,代碼行數:11,代碼來源:AmigaContext.py

示例5: multiselect

# 需要導入模塊: from fsbc.paths import Paths [as 別名]
# 或者: from fsbc.paths.Paths import contract_path [as 別名]
    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,代碼行數:57,代碼來源:floppy_manager.py

示例6: multi_select

# 需要導入模塊: from fsbc.paths import Paths [as 別名]
# 或者: from fsbc.paths.Paths import contract_path [as 別名]
    def multi_select(cls, parent=None):
        default_dir = FSGSDirectories.get_cdroms_dir()
        dialog = LauncherFilePicker(
            parent, gettext("Select Multiple CD-ROMs"), "cd", multiple=True
        )

        if not dialog.show_modal():
            return
        paths = dialog.get_paths()
        paths.sort()

        # checksum_tool = ChecksumTool(parent)
        for i, path in enumerate(paths):
            # sha1 = checksum_tool.checksum(path)
            sha1 = ""
            print("FIXME: not calculating CD checksum just yet")
            path = Paths.contract_path(path, default_dir)

            if i < 1:
                LauncherConfig.set_multiple(
                    [
                        ("cdrom_drive_{0}".format(i), path),
                        ("x_cdrom_drive_{0}_sha1".format(i), sha1),
                    ]
                )
            LauncherConfig.set_multiple(
                [
                    ("cdrom_image_{0}".format(i), path),
                    ("x_cdrom_image_{0}_sha1".format(i), sha1),
                ]
            )

        # blank the rest of the drives
        for i in range(len(paths), 1):
            LauncherConfig.set_multiple(
                [
                    ("cdrom_drive_{0}".format(i), ""),
                    ("x_cdrom_drive_{0}_sha1".format(i), ""),
                ]
            )

            # Config.set("x_cdrom_drive_{0}_sha1".format(i), "")
            # Config.set("x_cdrom_drive_{0}_name".format(i), "")
        # blank the rest of the image list
        for i in range(len(paths), Amiga.MAX_CDROM_IMAGES):
            LauncherConfig.set_multiple(
                [
                    ("cdrom_image_{0}".format(i), ""),
                    ("x_cdrom_image_{0}_sha1".format(i), ""),
                ]
            )
開發者ID:,項目名稱:,代碼行數:53,代碼來源:

示例7: fix

# 需要導入模塊: from fsbc.paths import Paths [as 別名]
# 或者: from fsbc.paths.Paths import contract_path [as 別名]
 def fix(key):
     if self.config.get(key):
         self.config[key] = Paths.contract_path(
             self.config.get(key), default_dir, force_real_case=False
         )
開發者ID:FrodeSolheim,項目名稱:fs-uae-launcher,代碼行數:7,代碼來源:valueconfigloader.py


注:本文中的fsbc.paths.Paths.contract_path方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。