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


Python PathsHelper.get_backup_filepath方法代码示例

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


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

示例1: run

# 需要导入模块: from AutoBackups.autobackups.paths_helper import PathsHelper [as 别名]
# 或者: from AutoBackups.autobackups.paths_helper.PathsHelper import get_backup_filepath [as 别名]
    def run(self):
        backup_per_day = settings.get('backup_per_day')

        window = self.window
        view = window.active_view()

        open_in_same_line = settings.get('open_in_same_line', True)
        if (open_in_same_line):
            (row, col) = view.rowcol(view.sel()[0].begin())
            self.curline = row + 1

        if (not backup_per_day):
            filepath = view.file_name()
            newname = PathsHelper.get_backup_filepath(filepath)
            if os.path.isfile(newname):
                window.open_file(newname)
            else:
                sublime.error_message(
                    'Backup for ' + filepath + ' not exists!')
        else:
            f_files = self.getData(False)

            if not f_files:
                sublime.error_message('Backups for this file not exists!')
                return

            backup_per_time = settings.get('backup_per_time')
            if (backup_per_time):
                window.show_quick_panel(f_files, self.timeFolders)
            else:
                window.show_quick_panel(f_files, self.openFile)
            return
开发者ID:bizoo,项目名称:sublimetext-autobackups,代码行数:34,代码来源:AutoBackups.py

示例2: run

# 需要导入模块: from AutoBackups.autobackups.paths_helper import PathsHelper [as 别名]
# 或者: from AutoBackups.autobackups.paths_helper.PathsHelper import get_backup_filepath [as 别名]
	def run(self, edit):
		backup_per_day = settings.get('backup_per_day')

		if (not backup_per_day):
			window = sublime.active_window()
			view = sublime.Window.active_view(window)
			filepath = view.file_name()
			newname = PathsHelper.get_backup_filepath(filepath)
			if os.path.isfile(newname):
				window.open_file(newname)
			else:
				sublime.error_message('Backup for ' + filepath + ' not exists!')
		else:
			f_files = self.getData(False)

			if not f_files:
				sublime.error_message('Backups for this file not exists!')
				return

			backup_per_time = settings.get('backup_per_time')
			if (backup_per_time):
				self.view.window().show_quick_panel(f_files, self.timeFolders)
			else:
				self.view.window().show_quick_panel(f_files, self.openFile)
			return
开发者ID:mateatslc,项目名称:sublimetext-autobackups,代码行数:27,代码来源:AutoBackups.py

示例3: save_backup

# 需要导入模块: from AutoBackups.autobackups.paths_helper import PathsHelper [as 别名]
# 或者: from AutoBackups.autobackups.paths_helper.PathsHelper import get_backup_filepath [as 别名]
	def save_backup(self, view, on_load_event):
		view_size = view.size()
		max_backup_file_size = settings.get('max_backup_file_size_bytes')
		if (view_size is None):
			self.console('Size of view not available')
			return

		if (max_backup_file_size is None):
			self.console('Max allowed size from config not available')
			return



		# don't save files above configured size
		if view_size > max_backup_file_size:
			self.console('Backup not saved, file too large (%d bytes)' % view.size())
			return

		filename = view.file_name()
		newname = PathsHelper.get_backup_filepath(filename)
		if newname == None:
			return

		buffer_id = view.buffer_id()
		content = filename+view.substr(sublime.Region(0, view_size))
		content = self.encode(content)
		current_hash = hashlib.md5(content).hexdigest()

		last_hash = ''
		try:
			last_hash = hashes[buffer_id]
		except Exception as e:
			last_hash = ''


		# not create file backup if no changes from last backup
		if (last_hash == current_hash):
			return

		# not create file backup if current file is backup
		if on_load_event & self.is_backup_file(filename):
			return

		# not create file if exists
		if on_load_event & os.path.isfile(newname):
			return

		(backup_dir, file_to_write) = os.path.split(newname)

		if os.access(backup_dir, os.F_OK) == False:
			os.makedirs(backup_dir)

		shutil.copy(filename, newname)

		hashes[buffer_id] = current_hash
		self.console('Backup saved to: '+newname.replace('\\', '/'))
开发者ID:mateatslc,项目名称:sublimetext-autobackups,代码行数:58,代码来源:AutoBackups.py

示例4: save_backup

# 需要导入模块: from AutoBackups.autobackups.paths_helper import PathsHelper [as 别名]
# 或者: from AutoBackups.autobackups.paths_helper.PathsHelper import get_backup_filepath [as 别名]
    def save_backup(self, view, on_load_event):
        if not view or view.is_read_only():
            return

        view_size = view.size()
        max_backup_file_size = settings.get('max_backup_file_size_bytes')
        if (view_size is None):
            self.console('Size of view not available')
            return

        if (max_backup_file_size is None):
            self.console('Max allowed size from config not available')
            return

        # don't save files above configured size
        if view_size > max_backup_file_size:
            self.console(
                'Backup not saved, file too large (%d bytes)' % view.size())
            return

        filename = view.file_name()
        if filename is None:
            return

        # not create file backup if current file is backup
        if on_load_event & self.is_backup_file(filename):
            return

        newname = PathsHelper.get_backup_filepath(filename, on_load_event)
        if newname is None:
            return

        last_backupname = lastbackups.get(filename)

        # not create file backup if no changes from last backup
        if filename and last_backupname:
            if filecmp.cmp(filename, last_backupname):
                return

        # not create file if exists
        if on_load_event & os.path.isfile(newname):
            return

        (backup_dir, file_to_write) = os.path.split(newname)

        if not os.access(backup_dir, os.F_OK):
            os.makedirs(backup_dir)

        shutil.copy(filename, newname)

        lastbackups[filename] = newname
        self.console('Backup saved to: ' + newname.replace('\\', '/'))
开发者ID:bizoo,项目名称:sublimetext-autobackups,代码行数:54,代码来源:AutoBackups.py


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