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


Python SideBarItem.path方法代码示例

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


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

示例1: on_done

# 需要导入模块: from sidebar.SideBarItem import SideBarItem [as 别名]
# 或者: from sidebar.SideBarItem.SideBarItem import path [as 别名]
	def on_done(self, paths, relative_to_project, name):
		if relative_to_project and s.get('new_files_relative_to_project_root'):
			paths = SideBarProject().getDirectories()
			if paths:
				paths = [SideBarItem(paths[0], False)]
			if not paths:
				paths = SideBarSelection(paths).getSelectedDirectoriesOrDirnames()
		else:
			paths = SideBarSelection(paths).getSelectedDirectoriesOrDirnames()
		if not paths:
			paths = SideBarProject().getDirectories()
			if paths:
				paths = [SideBarItem(paths[0], False)]
		if not paths:
			sublime.active_window().new_file()
		else:
			for item in paths:
				item = SideBarItem(item.join(name), False)
				if item.exists():
					sublime.error_message("Unable to create file, file or folder exists.")
					self.run(paths, name)
					return
				else:
					try:
						item.create()
						item.edit()
					except:
						sublime.error_message("Unable to create file:\n\n"+item.path())
						self.run(paths, name)
						return
			SideBarProject().refresh();
开发者ID:Blueprint-Marketing,项目名称:sublime-config,代码行数:33,代码来源:SideBar.py

示例2: on_done

# 需要导入模块: from sidebar.SideBarItem import SideBarItem [as 别名]
# 或者: from sidebar.SideBarItem.SideBarItem import path [as 别名]
 def on_done(self, paths, name):
     for folder_item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
         folder_item = SideBarItem(folder_item.join(name), True)
         if folder_item.exists():
             sublime.error_message("Unable to create folder, folder or file exists.")
             self.run(paths, name)
             return
         else:
             try:
                 folder_item.create()
                 init_item = SideBarItem(folder_item.join('__init__.py'), False)
                 init_item.create()
             except:
                 sublime.error_message("Unable to create file:\n\n" + init_item.path())
                 self.run(paths, name)
                 return
             if not folder_item.exists():
                 sublime.error_message("Unable to create folder:\n\n" + folder_item.path())
                 self.run(paths, name)
                 return
     SideBarProject().refresh()
开发者ID:jurgello,项目名称:SublimeText,代码行数:23,代码来源:new_python_package.py

示例3: on_done

# 需要导入模块: from sidebar.SideBarItem import SideBarItem [as 别名]
# 或者: from sidebar.SideBarItem.SideBarItem import path [as 别名]
	def on_done(self, paths, name):
		for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
			item = SideBarItem(item.join(name), True)
			if item.exists():
				sublime.error_message("Unable to create folder, folder or file exists.")
				self.run(paths, name)
				return
			else:
				item.create()
				if not item.exists():
					sublime.error_message("Unable to create folder:\n\n"+item.path())
					self.run(paths, name)
					return
		SideBarProject().refresh();
开发者ID:aokolovskis,项目名称:config,代码行数:16,代码来源:SideBar.py

示例4: run

# 需要导入模块: from sidebar.SideBarItem import SideBarItem [as 别名]
# 或者: from sidebar.SideBarItem.SideBarItem import path [as 别名]
	def run(self, paths = [], in_parent = 'False', test = 'True', replace = 'False'):
		s = sublime.load_settings("SideBarEnhancements/Clipboard.sublime-settings")

		cut = s.get('cut', '')
		copy = s.get('copy', '')

		already_exists_paths = []

		if SideBarSelection(paths).len() > 0:
			if in_parent == 'False':
				location = SideBarSelection(paths).getSelectedItems()[0].path()
			else:
				location = SideBarSelection(paths).getSelectedDirectoriesOrDirnames()[0].dirname()

			if os.path.isdir(location) == False:
				location = SideBarItem(os.path.dirname(location), True)
			else:
				location = SideBarItem(location, True)

			if cut != '':
				cut = cut.split("\n")
				for path in cut:
					path = SideBarItem(path, os.path.isdir(path))
					new  = os.path.join(location.path(), path.name())
					if test == 'True' and os.path.exists(new):
						already_exists_paths.append(new)
					elif test == 'False':
						if os.path.exists(new) and replace == 'False':
							pass
						else:
							try:
								if not path.move(new, replace == 'True'):
									sublime.error_message("Unable to cut and paste, destination exists.")
									return
							except:
								sublime.error_message("Unable to move:\n\n"+path.path()+"\n\nto\n\n"+new)
								return

			if copy != '':
				copy = copy.split("\n")
				for path in copy:
					path = SideBarItem(path, os.path.isdir(path))
					new  = os.path.join(location.path(), path.name())
					if test == 'True' and os.path.exists(new):
						already_exists_paths.append(new)
					elif test == 'False':
						if os.path.exists(new) and replace == 'False':
							pass
						else:
							try:
								if not path.copy(new, replace == 'True'):
									sublime.error_message("Unable to copy and paste, destination exists.")
									return
							except:
								sublime.error_message("Unable to copy:\n\n"+path.path()+"\n\nto\n\n"+new)
								return

			if test == 'True' and len(already_exists_paths):
				self.confirm(paths, in_parent, already_exists_paths)
			elif test == 'True' and not len(already_exists_paths):
				self.run(paths, in_parent, 'False', 'False')
			elif test == 'False':
				cut = s.set('cut', '')
				SideBarProject().refresh();
开发者ID:aokolovskis,项目名称:config,代码行数:66,代码来源:SideBar.py


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