本文整理匯總了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
示例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)
示例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))
#.........這裏部分代碼省略.........