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


Python PathsHelper.normalise_path方法代码示例

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


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

示例1: is_backup_file

# 需要导入模块: from AutoBackups.autobackups.paths_helper import PathsHelper [as 别名]
# 或者: from AutoBackups.autobackups.paths_helper.PathsHelper import normalise_path [as 别名]
    def is_backup_file(self, path):
        backup_per_time = settings.get('backup_per_time')
        path = PathsHelper.normalise_path(path)
        base_dir = PathsHelper.get_base_dir(False)
        base_dir = PathsHelper.normalise_path(base_dir)
        if (backup_per_time == 'folder'):
            base_dir = base_dir[:-7]

        backup_dir_len = len(base_dir)
        sub = path[0:backup_dir_len]

        if sub == base_dir:
            return True
        else:
            return False
开发者ID:bizoo,项目名称:sublimetext-autobackups,代码行数:17,代码来源:AutoBackups.py

示例2: run

# 需要导入模块: from AutoBackups.autobackups.paths_helper import PathsHelper [as 别名]
# 或者: from AutoBackups.autobackups.paths_helper.PathsHelper import normalise_path [as 别名]
    def run(self):
        path = self.window.active_view().file_name()

        recover_path = os.path.dirname(path) if path else self.window.folders()[0]
        normalized_path = PathsHelper.normalise_path(recover_path)
        backups_path = PathsHelper.get_base_dir(True)

        confirmation = sublime.ok_cancel_dialog(self.DIALOG_TEXT % recover_path)
        if confirmation:
            restore_folder(backups_path, normalized_path, recover_path)
开发者ID:cryzed,项目名称:sublimetext-autobackups,代码行数:12,代码来源:AutoBackups.py

示例3: getData

# 需要导入模块: from AutoBackups.autobackups.paths_helper import PathsHelper [as 别名]
# 或者: from AutoBackups.autobackups.paths_helper.PathsHelper import normalise_path [as 别名]
    def getData(self, time_folder):
        filename = PathsHelper.normalise_path(
            self.window.active_view().file_name(), True)
        basedir = PathsHelper.get_base_dir(True)

        backup_per_time = settings.get('backup_per_time')
        if (backup_per_time):
            if (backup_per_time == 'folder'):
                f_files = []
                if (time_folder is not False):
                    tm_folders = self.getData(False)
                    tm_folder = tm_folders[time_folder][0]
                    basedir = basedir + '/' + tm_folder

                    if (not os.path.isdir(basedir)):
                        sublime.error_message(
                            'Folder ' + basedir + ' not found!')

                    for folder in os.listdir(basedir):
                        fl = basedir + '/' + folder + '/' + filename
                        match = re.search(r"^[0-9+]{6}$", folder)
                        if os.path.isfile(fl) and match is not None:
                            folder_name, file_name = os.path.split(fl)
                            f_file = []
                            thetime = self.formatTime(folder)
                            f_file.append(thetime + ' - ' + file_name)
                            f_file.append(fl)
                            f_files.append(f_file)
                else:
                    path, flname = os.path.split(filename)
                    (filepart, extpart) = os.path.splitext(flname)
                    for folder in os.listdir(basedir):
                        match = re.search(
                            r"^[0-9+]{4}-[0-9+]{2}-[0-9+]{2}$", folder)
                        if match is not None:
                            folder_name, file_name = os.path.split(filename)
                            f_file = []
                            basedir2 = basedir + '/' + folder
                            count = 0
                            last = ''
                            for folder2 in os.listdir(basedir2):
                                match = re.search(r"^[0-9+]{6}$", folder2)
                                if match is not None:
                                    basedir3 = basedir + '/' + folder + \
                                        '/' + folder2 + '/' + filename
                                    if os.path.isfile(basedir3):
                                        count += 1
                                        last = folder2
                            if (count > 0):
                                f_file.append(folder)
                                f_file.append(
                                    'Backups: ' + str(count) + ', Last edit: ' + self.formatTime(last))
                                f_files.append(f_file)
            elif (backup_per_time == 'file'):
                f_files = []
                if (time_folder is not False):
                    tm_folders = self.getData(False)
                    tm_folder = tm_folders[time_folder][0]
                    path, flname = os.path.split(filename)
                    basedir = basedir + '/' + tm_folder + '/' + path
                    (filepart, extpart) = os.path.splitext(flname)

                    if (not os.path.isdir(basedir)):
                        sublime.error_message(
                            'Folder ' + basedir + ' not found!')

                    for folder in os.listdir(basedir):
                        fl = basedir + '/' + folder
                        match = re.search(
                            r"^" + re.escape(filepart) + "_([0-9+]{6})" + re.escape(extpart) + "$", folder)

                        if os.path.isfile(fl) and match is not None:
                            thetime = self.formatTime(match.group(1))
                            f_file = []
                            f_file.append(thetime + ' - ' + flname)
                            f_file.append(fl)
                            f_files.append(f_file)
                else:
                    path, flname = os.path.split(filename)
                    (filepart, extpart) = os.path.splitext(flname)
                    for folder in os.listdir(basedir):
                        match = re.search(
                            r"^[0-9+]{4}-[0-9+]{2}-[0-9+]{2}$", folder)
                        if match is not None:
                            folder_name, file_name = os.path.split(filename)
                            f_file = []
                            basedir2 = basedir + '/' + folder + '/' + path
                            count = 0
                            last = ''
                            if (os.path.isdir(basedir2)):
                                for sfile in os.listdir(basedir2):
                                    match = re.search(
                                        r"^" + re.escape(filepart) + "_([0-9+]{6})" + re.escape(extpart) + "$", sfile)
                                    if match is not None:
                                        count += 1
                                        last = match.group(1)
                            if (count > 0):
                                f_file.append(folder)
                                f_file.append(
                                    'Backups: ' + str(count) + ', Last edit: ' + self.formatTime(last))
#.........这里部分代码省略.........
开发者ID:bizoo,项目名称:sublimetext-autobackups,代码行数:103,代码来源:AutoBackups.py


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