本文整理汇总了Python中ninja_ide.core.file_manager.create_path函数的典型用法代码示例。如果您正苦于以下问题:Python create_path函数的具体用法?Python create_path怎么用?Python create_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: expand_tab_name
def expand_tab_name(self, title):
"""Expand the tab title to differentiate files with the same name.
The way it is currently implemented, it will only change the first
conflicting title passed in, because it only searches until the new
title isn't in the tab titles.
"""
if title == 'New Document':
return
elif title not in self.titles:
self.titles.append(title)
return
indexes = [i for i in range(self.count())
if type(self.widget(i)) is editor.Editor and
self.tabText(i) == title and
self.widget(i).ID] # self.widget.ID returns the basename
self.dontLoopInExpandTitle = True
for i in indexes:
newName = file_manager.create_path(
file_manager.get_basename(
file_manager.get_folder(self.widget(i).ID)), title)
while newName in self.titles:
# Keep prepending the folder name onto the title until it
# does not conflict.
path = self.widget(i).ID
tempDir = path[:path.rfind(newName)]
newName = file_manager.create_path(
file_manager.get_basename(
file_manager.get_folder(tempDir)),
'..',
title)
self.titles.append(newName)
self.setTabText(i, newName)
self.dontLoopInExpandTitle = False
开发者ID:DevNIX,项目名称:ninja-ide,代码行数:34,代码来源:tab_widget.py
示例2: expand_tab_name
def expand_tab_name(self, title):
title = unicode(title)
if title == 'New Document':
return
elif title not in self.titles:
self.titles.append(title)
return
indexes = [i for i in xrange(self.count())
if type(self.widget(i)) is editor.Editor and \
self.tabText(i) == title and \
self.widget(i).ID]
self.dontLoopInExpandTitle = True
for i in indexes:
newName = file_manager.create_path(
file_manager.get_basename(
file_manager.get_folder(self.widget(i).ID)),
title)
while newName in self.titles:
path = self.widget(i).ID
tempDir = path[:path.rfind(newName)]
newName = file_manager.create_path(
file_manager.get_basename(
file_manager.get_folder(tempDir)),
'..',
title)
self.titles.append(newName)
self.setTabText(i, newName)
self.dontLoopInExpandTitle = False
开发者ID:aguzubiaga,项目名称:ninja-ide,代码行数:28,代码来源:tab_widget.py
示例3: on_wizard_finish
def on_wizard_finish(self, wizard):
global PROJECT_TYPE
ids = wizard.pageIds()
# Manipulate default data for NINJA-IDE projects
page = wizard.page(ids[2])
place = str(page.txtPlace.text())
if place == '':
QMessageBox.critical(self, 'Incorrect Location',
'The project couldn\'t be create')
return
folder = str(page.txtFolder.text())
path = file_manager.create_path(place, folder)
if not file_manager.folder_exists(path):
file_manager.create_folder(path)
project = {}
name = unicode(page.txtName.text())
project['name'] = name
project['project-type'] = PROJECT_TYPE
project['description'] = unicode(page.txtDescription.toPlainText())
project['license'] = unicode(page.cboLicense.currentText())
project['venv'] = unicode(page.vtxtPlace.text())
# Manipulate plugin project data
page = wizard.page(ids[1])
json_manager.create_ninja_project(path, name, project)
plugin_dict = self.create_descriptor(page, path)
self.create_plugin_class(page, path, plugin_dict)
# Load the project!
wizard._load_project(path)
开发者ID:alekibango,项目名称:ninja-ide-plugins,代码行数:32,代码来源:pluginProject.py
示例4: execute_project
def execute_project(self):
"""Execute the project marked as Main Project."""
mainFile = self.ide.explorer.get_project_main_file()
if not mainFile and self.ide.explorer._treeProjects and \
self.ide.explorer._treeProjects._actualProject:
self.ide.explorer._treeProjects.open_project_properties()
elif mainFile:
self.save_project()
path = self.ide.explorer.get_actual_project()
#emit a signal for plugin!
self.emit(SIGNAL("projectExecuted(QString)"), path)
# load our jutsus!
project = json_manager.read_ninja_project(path)
python_exec = project.get('venv', False)
if not python_exec:
python_exec = project.get('pythonPath', 'python')
PYTHONPATH = project.get('PYTHONPATH', None)
params = project.get('programParams', '')
preExec = project.get('preExecScript', '')
postExec = project.get('postExecScript', '')
mainFile = file_manager.create_path(path, mainFile)
self.ide.misc.run_application(mainFile, pythonPath=python_exec,
PYTHONPATH=PYTHONPATH,
programParams=params, preExec=preExec, postExec=postExec)
开发者ID:SlashRoot,项目名称:ninja-ide,代码行数:25,代码来源:actions.py
示例5: _copy_file
def _copy_file(self):
item = self.currentItem()
if item.parent() is None:
pathForFile = item.path
else:
pathForFile = os.path.join(item.path, unicode(item.text(0)))
pathProject = self.get_selected_project_path()
addToProject = ui_tools.AddToProject(pathProject, self)
addToProject.setWindowTitle(self.tr("Copy File to"))
addToProject.exec_()
if not addToProject.pathSelected:
return
name = unicode(QInputDialog.getText(None,
self.tr("Copy File"),
self.tr("File Name:"))[0])
if not name:
QMessageBox.information(self, self.tr("Indalid Name"),
self.tr("The file name is empty, please enter a name"))
return
path = file_manager.create_path(
unicode(addToProject.pathSelected), name)
try:
content = file_manager.read_file_content(pathForFile)
path = file_manager.store_file_content(path, content, newFile=True)
self.add_existing_file(path)
except file_manager.NinjaFileExistsException, ex:
QMessageBox.information(self, self.tr("File Already Exists"),
self.tr("Invalid Path: the file '%s' already exists." % \
ex.filename))
开发者ID:sanyaade,项目名称:ninja-ide,代码行数:29,代码来源:tree_projects_widget.py
示例6: _copy_file
def _copy_file(self):
#get the selected QTreeWidgetItem
item = self.currentItem()
if item.parent() is None:
pathForFile = item.path
else:
pathForFile = os.path.join(item.path, item.text(0))
pathProjects = [p.path for p in self.get_open_projects()]
addToProject = ui_tools.AddToProject(pathProjects, self)
addToProject.setWindowTitle(self.tr("Copy File to"))
addToProject.exec_()
if not addToProject.pathSelected:
return
name = QInputDialog.getText(self, self.tr("Copy File"),
self.tr("File Name:"), text=item.text(0))[0]
if not name:
QMessageBox.information(self, self.tr("Invalid Name"),
self.tr("The file name is empty, please enter a name"))
return
path = file_manager.create_path(addToProject.pathSelected, name)
try:
content = file_manager.read_file_content(pathForFile)
path = file_manager.store_file_content(path, content, newFile=True)
self.add_existing_file(path)
except file_manager.NinjaFileExistsException as ex:
QMessageBox.information(self, self.tr("File Already Exists"),
self.tr("Invalid Path: the file '%s' already exists." %
ex.filename))
开发者ID:Bengt,项目名称:ninja-ide,代码行数:28,代码来源:tree_projects_widget.py
示例7: _add_file_to_project
def _add_file_to_project(self, path):
"""Add the file for 'path' in the project the user choose here."""
pathProject = [self.ide.explorer.get_actual_project()]
addToProject = ui_tools.AddToProject(pathProject, self.ide)
addToProject.exec_()
if not addToProject.pathSelected:
return
editorWidget = self.ide.mainContainer.get_actual_editor()
if not editorWidget.ID:
name = unicode(QInputDialog.getText(None,
self.tr("Add File To Project"), self.tr("File Name:"))[0])
if not name:
QMessageBox.information(self, self.tr("Invalid Name"),
self.tr("The file name is empty, please enter a name"))
return
else:
name = file_manager.get_basename(editorWidget.ID)
path = file_manager.create_path(
unicode(addToProject.pathSelected), name)
try:
path = file_manager.store_file_content(
path, editorWidget.get_text(), newFile=True)
editorWidget.ID = path
self.ide.explorer.add_existing_file(path)
self.ide.change_window_title(path)
name = file_manager.get_basename(path)
self.ide.mainContainer.actualTab.setTabText(
self.ide.mainContainer.actualTab.currentIndex(), name)
editorWidget._file_saved()
except file_manager.NinjaFileExistsException, ex:
QMessageBox.information(self, self.tr("File Already Exists"),
self.tr("Invalid Path: the file '%s' already exists." % \
ex.filename))
开发者ID:alekibango,项目名称:ninja-ide,代码行数:33,代码来源:actions.py
示例8: _move_file
def _move_file(self):
item = self.currentItem()
if item.parent() is None:
pathForFile = item.path
else:
pathForFile = os.path.join(item.path, item.text(0))
pathProjects = [p.path for p in self.get_open_projects()]
addToProject = ui_tools.AddToProject(pathProjects, self)
addToProject.setWindowTitle(self.tr("Copy File to"))
addToProject.exec_()
if not addToProject.pathSelected:
return
name = file_manager.get_basename(pathForFile)
path = file_manager.create_path(addToProject.pathSelected, name)
try:
content = file_manager.read_file_content(pathForFile)
path = file_manager.store_file_content(path, content, newFile=True)
file_manager.delete_file(pathForFile)
index = item.parent().indexOfChild(item)
item.parent().takeChild(index)
self.add_existing_file(path)
except file_manager.NinjaFileExistsException as ex:
QMessageBox.information(self, self.tr("File Already Exists"),
self.tr("Invalid Path: the file '%s' already exists." %
ex.filename))
开发者ID:Bengt,项目名称:ninja-ide,代码行数:25,代码来源:tree_projects_widget.py
示例9: _replace_results
def _replace_results(self):
result = QMessageBox.question(self, self.tr("Replace Files Contents"),
self.tr("Are you sure you want to replace the content in "
"this files?\n(The change is not reversible)"),
buttons=QMessageBox.Yes | QMessageBox.No)
if result == QMessageBox.Yes:
for index in range(self._result_widget.topLevelItemCount()):
parent = self._result_widget.topLevelItem(index)
root_dir_name = parent.dir_name_root
file_name = parent.text(0)
file_path = file_manager.create_path(root_dir_name, file_name)
try:
content = file_manager.read_file_content(file_path)
pattern = self._find_widget.pattern_line_edit.text()
flags = 0
if not self._find_widget.case_checkbox.isChecked():
flags |= re.IGNORECASE
if self._find_widget.type_checkbox.isChecked():
pattern = r'\b%s\b' % pattern
new_content = re.sub(pattern,
self._find_widget.replace_line.text(),
content, flags=flags)
file_manager.store_file_content(file_path,
new_content, False)
except:
print('File: %s content, could not be replaced' %
file_path)
开发者ID:AlexaProjects,项目名称:Alexa2,代码行数:28,代码来源:find_in_files.py
示例10: _replace_results
def _replace_results(self):
result = QMessageBox.question(self, self.tr("Replace Files Contents"),
self.tr("Are you sure you want to replace the content in "
"this files?\n(The change is not reversible)"),
buttons=QMessageBox.Yes | QMessageBox.No)
if result == QMessageBox.Yes:
for index in xrange(self._result_widget.topLevelItemCount()):
parent = self._result_widget.topLevelItem(index)
root_dir_name = unicode(parent.dir_name_root)
file_name = unicode(parent.text(0))
file_path = file_manager.create_path(root_dir_name, file_name)
file_object = QFile(file_path)
if not file_object.open(QFile.ReadOnly):
return
stream = QTextStream(file_object)
content = stream.readAll()
file_object.close()
pattern = self._find_widget.pattern_line_edit.text()
case_sensitive = self._find_widget.case_checkbox.isChecked()
type_ = QRegExp.RegExp if \
self._find_widget.type_checkbox.isChecked() else \
QRegExp.FixedString
target = QRegExp(pattern, case_sensitive, type_)
content.replace(target, self._find_widget.replace_line.text())
file_manager.store_file_content(file_path, content, False)
开发者ID:alekibango,项目名称:ninja-ide,代码行数:25,代码来源:find_in_files.py
示例11: _move_file
def _move_file(self):
item = self.currentItem()
if item.parent() is None:
pathForFile = item.path
else:
pathForFile = os.path.join(item.path, item.text(0))
pathProjects = [p.path for p in self.get_open_projects()]
addToProject = ui_tools.AddToProject(pathProjects, self)
addToProject.setWindowTitle(_translate("TreeProjectsWidget", "Copy File to"))
addToProject.exec_()
if not addToProject.pathSelected:
return
name = file_manager.get_basename(pathForFile)
path = file_manager.create_path(addToProject.pathSelected, name)
try:
content = file_manager.read_file_content(pathForFile)
path = file_manager.store_file_content(path, content, newFile=True)
file_manager.delete_file(pathForFile)
index = item.parent().indexOfChild(item)
item.parent().takeChild(index)
self.add_existing_file(path)
# Update path of opened file
main = main_container.MainContainer()
if main.is_open(pathForFile):
widget = main.get_widget_for_path(pathForFile)
if widget:
widget.ID = path
except file_manager.NinjaFileExistsException as ex:
QMessageBox.information(self, _translate("TreeProjectsWidget", "File Already Exists"),
(_translate("TreeProjectsWidget", "Invalid Path: the file '%s' already exists.") %
ex.filename))
开发者ID:Salmista-94,项目名称:Ninja_PyQt5,代码行数:31,代码来源:tree_projects_widget.py
示例12: _go_to
def _go_to(self, item, val):
if item.text(1):
parent = item.parent()
file_name = parent.text(0)
lineno = item.text(1)
root_dir_name = parent.dir_name_root
file_path = file_manager.create_path(root_dir_name, file_name)
#open the file and jump_to_line
self._main_container.open_file(file_path)
self._main_container.editor_jump_to_line(lineno=int(lineno) - 1)
开发者ID:AlexaProjects,项目名称:Alexa2,代码行数:10,代码来源:find_in_files.py
示例13: _delete_file
def _delete_file(self):
item = self.currentItem()
val = QMessageBox.question(self, self.tr("Delete File"),
self.tr("Do you want to delete the following file: ") \
+ os.path.join(item.path, unicode(item.text(0))),
QMessageBox.Yes, QMessageBox.No)
if val == QMessageBox.Yes:
path = file_manager.create_path(item.path, unicode(item.text(0)))
file_manager.delete_file(item.path, unicode(item.text(0)))
self.removeItemWidget(item, 0)
mainContainer = main_container.MainContainer()
if mainContainer.is_open(path):
mainContainer.close_deleted_file(path)
开发者ID:dawee,项目名称:ninja-ide,代码行数:13,代码来源:tree_projects_widget.py
示例14: _delete_file
def _delete_file(self):
item = self.currentItem()
val = QMessageBox.question(self, self.tr("Delete File"),
self.tr("Do you want to delete the following file: ")
+ os.path.join(item.path, item.text(0)),
QMessageBox.Yes, QMessageBox.No)
if val == QMessageBox.Yes:
path = file_manager.create_path(item.path, item.text(0))
file_manager.delete_file(item.path, item.text(0))
index = item.parent().indexOfChild(item)
item.parent().takeChild(index)
mainContainer = main_container.MainContainer()
if mainContainer.is_open(path):
mainContainer.close_deleted_file(path)
开发者ID:Bengt,项目名称:ninja-ide,代码行数:14,代码来源:tree_projects_widget.py
示例15: execute_project
def execute_project(self):
mainFile = self.ide.explorer.get_project_main_file()
if not mainFile and self.ide.explorer._treeProjects and \
self.ide.explorer._treeProjects._actualProject:
self.ide.explorer._treeProjects.open_project_properties()
elif mainFile:
self.save_project()
#emit a signal for plugin!
self.emit(SIGNAL("projectExecuted(QString)"), mainFile)
path = self.ide.explorer.get_actual_project()
project = json_manager.read_ninja_project(path)
venv = project.get('venv', False)
params = project.get('programParams', '')
mainFile = file_manager.create_path(path, mainFile)
self.ide.misc.run_application(mainFile, pythonPath=venv,
programParams=params)
开发者ID:sanyaade,项目名称:ninja-ide,代码行数:16,代码来源:actions.py
示例16: _refresh_project
def _refresh_project(self, item=None):
if item is None:
item = self.currentItem()
parentItem = self._get_project_root(item)
if parentItem is None:
return
if item.parent() is None:
path = item.path
else:
path = file_manager.create_path(item.path, item.text(0))
thread = ui_tools.ThreadProjectExplore()
self._thread_execution[path] = thread
thread.folderDataRefreshed.connect(self._callback_refresh_project)
thread.finished.connect(self._clean_threads)
thread.refresh_project(path, item, parentItem.extensions)
开发者ID:Salmista-94,项目名称:Ninja_PyQt5,代码行数:16,代码来源:tree_projects_widget.py
示例17: _refresh_project
def _refresh_project(self, item=None):
if item is None:
item = self.currentItem()
parentItem = self._get_project_root(item)
if parentItem is None:
return
if item.parent() is None:
path = item.path
else:
path = file_manager.create_path(item.path, unicode(item.text(0)))
thread = ui_tools.ThreadExecution(
self._thread_refresh_project, args=[path, item, parentItem])
self._thread_execution[path] = thread
self.connect(thread, SIGNAL("executionFinished(PyQt_PyObject)"),
self._callback_refresh_project)
thread.start()
开发者ID:alekibango,项目名称:ninja-ide,代码行数:17,代码来源:tree_projects_widget.py
示例18: _refresh_project
def _refresh_project(self, item=None):
if item is None:
item = self.currentItem()
parentItem = self._get_project_root(item)
if parentItem is None:
return
if item.parent() is None:
path = item.path
else:
path = file_manager.create_path(item.path, unicode(item.text(0)))
if parentItem.extensions != settings.SUPPORTED_EXTENSIONS:
folderStructure = file_manager.open_project_with_extensions(
path, parentItem.extensions)
else:
folderStructure = file_manager.open_project(path)
if folderStructure.get(path, [None, None])[1] is not None:
folderStructure[path][1].sort()
else:
return
item.takeChildren()
self._load_folder(folderStructure, path, item)
item.setExpanded(True)
开发者ID:dawee,项目名称:ninja-ide,代码行数:22,代码来源:tree_projects_widget.py
示例19: _add_file_to_project
def _add_file_to_project(self, path):
"""Add the file for 'path' in the project the user choose here."""
pathProject = [self.ide.explorer.get_actual_project()]
addToProject = ui_tools.AddToProject(pathProject, self.ide)
addToProject.exec_()
if not addToProject.pathSelected:
return
editorWidget = self.ide.mainContainer.get_actual_editor()
if not editorWidget.ID:
name = QInputDialog.getText(None,
_translate("_s_Actions", "Add File To Project"), _translate("_s_Actions", "File Name:"))[0]
if not name:
QMessageBox.information(None, _translate("_s_Actions", "Invalid Name"),
_translate("_s_Actions", "The file name is empty, please enter a name"))
return
else:
name = file_manager.get_basename(editorWidget.ID)
path = file_manager.create_path(addToProject.pathSelected, name)
try:
path = file_manager.store_file_content(
path, editorWidget.get_text(), newFile=True)
self.ide.mainContainer._file_watcher.allow_kill = False
if path != editorWidget.ID:
self.ide.mainContainer.remove_standalone_watcher(
editorWidget.ID)
editorWidget.ID = path
self.ide.mainContainer.add_standalone_watcher(path)
self.ide.mainContainer._file_watcher.allow_kill = True
self.ide.explorer.add_existing_file(path)
self.ide.change_window_title(path)
name = file_manager.get_basename(path)
self.ide.mainContainer.actualTab.setTabText(
self.ide.mainContainer.actualTab.currentIndex(), name)
editorWidget._file_saved()
except file_manager.NinjaFileExistsException as ex:
QMessageBox.information(None, _translate("_s_Actions", "File Already Exists"),
(_translate("_s_Actions", "Invalid Path: the file '%s' already exists.") %
ex.filename))
开发者ID:Salmista-94,项目名称:Ninja_PyQt5,代码行数:38,代码来源:actions.py
示例20: start
def start(listener, filenames=None, projects_path=None, extra_plugins=None):
app = QApplication(sys.argv)
QCoreApplication.setOrganizationName('NINJA-IDE')
QCoreApplication.setOrganizationDomain('NINJA-IDE')
QCoreApplication.setApplicationName('NINJA-IDE')
app.setWindowIcon(QIcon(resources.IMAGES['icon']))
# Create and display the splash screen
splash_pix = QPixmap(resources.IMAGES['splash'])
splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
splash.setMask(splash_pix.mask())
splash.show()
app.processEvents()
# Set the cursor to unblinking
app.setCursorFlashTime(0)
#Set the codec for strings (QString)
QTextCodec.setCodecForCStrings(QTextCodec.codecForName('utf-8'))
#Translator
qsettings = QSettings()
language = QLocale.system().language()
lang = unicode(qsettings.value(
'preferences/interface/language', language).toString()) + '.qm'
lang_path = file_manager.create_path(resources.LANGS, unicode(lang))
if file_manager.file_exists(lang_path):
settings.LANGUAGE = lang_path
elif file_manager.file_exists(file_manager.create_path(
resources.LANGS_DOWNLOAD, unicode(lang))):
settings.LANGUAGE = file_manager.create_path(
resources.LANGS_DOWNLOAD, unicode(lang))
translator = QTranslator()
if settings.LANGUAGE:
translator.load(settings.LANGUAGE)
app.installTranslator(translator)
#Loading Syntax
splash.showMessage("Loading Syntax", Qt.AlignRight | Qt.AlignTop, Qt.black)
json_manager.load_syntax()
#Read Settings
splash.showMessage("Loading Settings", Qt.AlignRight | Qt.AlignTop,
Qt.black)
settings.load_settings()
#Loading Themes
splash.showMessage("Loading Themes", Qt.AlignRight | Qt.AlignTop, Qt.black)
scheme = unicode(qsettings.value('preferences/editor/scheme',
"default").toString())
if scheme != 'default':
scheme = file_manager.create_path(resources.EDITOR_SKINS,
scheme + '.color')
if file_manager.file_exists(scheme):
resources.CUSTOM_SCHEME = json_manager.parse(open(scheme))
#Loading Shortcuts
resources.load_shortcuts()
#Loading GUI
splash.showMessage("Loading GUI", Qt.AlignRight | Qt.AlignTop, Qt.black)
ide = IDE()
#Showing GUI
ide.show()
#Connect listener signals
ide.connect(listener, SIGNAL("fileOpenRequested(QString)"),
ide.open_file)
ide.connect(listener, SIGNAL("projectOpenRequested(QString)"),
ide.open_project)
#Loading Session Files
splash.showMessage("Loading Files and Projects",
Qt.AlignRight | Qt.AlignTop, Qt.black)
#Files in Main Tab
mainFiles = qsettings.value('openFiles/mainTab', []).toList()
tempFiles = []
for file_ in mainFiles:
fileData = file_.toList()
tempFiles.append((unicode(fileData[0].toString()),
fileData[1].toInt()[0]))
mainFiles = tempFiles
#Files in Secondary Tab
secondaryFiles = qsettings.value('openFiles/secondaryTab', []).toList()
tempFiles = []
for file_ in secondaryFiles:
fileData = file_.toList()
tempFiles.append((unicode(fileData[0].toString()),
fileData[1].toInt()[0]))
secondaryFiles = tempFiles
#Projects
projects = qsettings.value('openFiles/projects', []).toList()
projects = [unicode(project.toString()) for project in projects]
#Include files received from console args
if filenames:
mainFiles += [(f, 0) for f in filenames]
#Include projects received from console args
if projects_path:
projects += projects_path
ide.load_session_files_projects(mainFiles, secondaryFiles, projects)
#Load external plugins
#.........这里部分代码省略.........
开发者ID:Fieldbyte,项目名称:ninja-ide,代码行数:101,代码来源:ide.py
注:本文中的ninja_ide.core.file_manager.create_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论