本文整理汇总了Python中ninja_ide.tools.json_manager.create_ninja_project函数的典型用法代码示例。如果您正苦于以下问题:Python create_ninja_project函数的具体用法?Python create_ninja_project怎么用?Python create_ninja_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_ninja_project函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_layout
def create_layout(self, wizard):
"""
Create set of folders and files required for a basic python project
"""
# Create project path
project_path = os.path.join(self.path, self.name)
self._create_path(project_path)
# Create a single init file
filepath = os.path.join(project_path, "__init__.py")
with open(filepath, "w") as base_init:
self.init_file(base_init, filepath)
# Create a setup.py
filepath = os.path.join(project_path, "setup.py")
with open(filepath, "w") as base_setup:
self.init_file(base_setup, filepath)
base_setup.write(SETUP_PY_FILE % self.name)
# Create a basic main file
filepath = os.path.join(project_path, "main.py")
with open(filepath, "w") as base_main:
self.init_file(base_main, filepath)
base_main.write(BASIC_HELLO % self.name)
# Create .nja file
project = {}
project["name"] = self.name
project["project-type"] = self.category
project["mainFile"] = "main.py"
project["description"] = wizard.field("description")
json_manager.create_ninja_project(project_path, self.name, project)
# Open project in Explorer
self._open_project(project_path)
示例2: ChangeOcrDataFolder
def ChangeOcrDataFolder(self, fileName):
#the code goes here!
#print fileName
dataPath = ""
f = open(fileName)
for line in f:
#print line
if "Ocr.Data =" in line or "Ocr.Data=" in line:
try:
if line.index('#') < line.index('Ocr.Data'):
continue
except:
pass
dataPath = line.split('=')[1]
dataPath = dataPath.strip()
#print dataPath
f.close()
if dataPath != "":
try:
jsfile = json_manager.read_json(fileName.replace(".py", ".nja"))
jsfile['ocrdatafolder'] = dataPath.replace("\\\\", "\\")
jsfile['ocrdatafolder'] = jsfile['ocrdatafolder'].replace("\"", "")
#print jsfile
fileNameWithExtension = os.path.split(fileName)[1]
fileNameWithOutExtension = os.path.splitext(fileNameWithExtension)[0]
json_manager.create_ninja_project(os.path.split(fileName)[0], fileNameWithOutExtension, jsfile)
except:
pass
示例3: create_layout
def create_layout(self):
"""
Create set of folders and files required for a basic python project
"""
# Create project path
project_path = os.path.join(self.path, self.name)
self._create_path(project_path)
# Create a single init file
filepath = os.path.join(project_path, "__init__.py")
with open(filepath, "w") as base_init:
self.init_file(base_init, filepath)
# Create a setup.py
filepath = os.path.join(project_path, "setup.py")
with open(filepath, "w") as base_setup:
self.init_file(base_setup, filepath)
base_setup.write(SETUP_PY_FILE % self.name)
# Create a basic main file
filepath = os.path.join(project_path, "main.py")
with open(filepath, "w") as base_main:
self.init_file(base_main, filepath)
base_main.write(BASIC_HELLO % self.name)
from ninja_ide.tools import json_manager
project = {}
project["name"] = self.name
project["license"] = self.license_text
json_manager.create_ninja_project(project_path, self.name, project)
示例4: 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)
示例5: 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])
path = unicode(page.txtPlace.text())
if not path:
QMessageBox.critical(self, self.tr("Incorrect Location"),
self.tr("The project couldn\'t be create"))
return
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])
# Create a folder to contain all the project data (<path>/<name>/)
path = os.path.join(path, name)
file_manager.create_folder(path, add_init_file=False)
# Create the .nja file
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)
示例6: save_properties
def save_properties(self):
if self.projectData.name.text().strip() == '':
QMessageBox.critical(self, self.tr("Properties Invalid"),
self.tr("The Project must have a name."))
return
tempName = self._item.name
self._item.name = self.projectData.name.text()
self._item.description = self.projectData.description.toPlainText()
self._item.license = self.projectData.cboLicense.currentText()
self._item.mainFile = self.projectExecution.path.text()
self._item.url = self.projectData.url.text()
self._item.projectType = self.projectData.txtType.text()
# FIXME
self._item.pythonPath = self.projectExecution.txtPythonPath.text()
self._item.PYTHONPATH = self.projectExecution.PYTHONPATH.toPlainText()
self._item.additional_builtins = filter(
lambda e: e, # remove empty names
self.projectExecution.additional_builtins.text().split(' '))
self._item.preExecScript = self.projectExecution.txtPreExec.text()
self._item.postExecScript = self.projectExecution.txtPostExec.text()
self._item.programParams = self.projectExecution.txtParams.text()
self._item.venv = self.projectExecution.txtVenvPath.text()
extensions = self.projectData.txtExtensions.text().split(', ')
self._item.extensions = tuple(extensions)
self._item.indentation = self.projectData.spinIndentation.value()
self._item.useTabs = self.projectData.checkUseTabs.isChecked()
related = self.projectMetadata.txt_projects.toPlainText()
related = [path for path in related.split('\n') if path != '']
self._item.related_projects = related
#save project properties
project = {}
project['name'] = self._item.name
project['description'] = self._item.description
project['url'] = self._item.url
project['license'] = self._item.license
project['mainFile'] = self._item.mainFile
project['project-type'] = self._item.projectType
project['supported-extensions'] = self._item.extensions
project['indentation'] = self._item.indentation
project['use-tabs'] = self._item.useTabs
project['pythonPath'] = self._item.pythonPath # FIXME
project['PYTHONPATH'] = self._item.PYTHONPATH
project['additional_builtins'] = self._item.additional_builtins
project['preExecScript'] = self._item.preExecScript
project['postExecScript'] = self._item.postExecScript
project['venv'] = self._item.venv
project['programParams'] = self._item.programParams
project['relatedProjects'] = self._item.related_projects
if tempName != self._item.name and \
file_manager.file_exists(self._item.path, tempName + '.nja'):
file_manager.delete_file(self._item.path, tempName + '.nja')
json_manager.create_ninja_project(
self._item.path, self._item.name, project)
self._item.setText(0, self._item.name)
self._item.setToolTip(0, self._item.name)
if self._item.extensions != settings.SUPPORTED_EXTENSIONS:
self._item._parent._refresh_project(self._item)
self._item.update_paths()
self.close()
示例7: create_layout
def create_layout(self, wizard):
base_class = wizard.field("base_class")
class_name = wizard.field("class_name").title()
module = base_class.lower()[1:]
# Create project path
project_path = os.path.join(self.path, self.name)
self._create_path(project_path)
# Create main file
filepath = os.path.join(project_path, "main.py")
with open(filepath, "w") as base_main:
self.init_file(base_main, filepath)
base_main.write(MAIN.format(module=module, classname=class_name))
# Create widget file
filepath = os.path.join(project_path, module + ".py")
with open(filepath, "w") as widget_file:
self.init_file(widget_file, filepath)
widget_file.write(
WIDGET.format(baseclass=base_class, classname=class_name))
# Create ninja project file
project = {}
project["name"] = self.name
project["project-type"] = self.category
project["mainFile"] = "main.py"
json_manager.create_ninja_project(project_path, self.name, project)
self._open_project(project_path)
示例8: on_wizard_finish
def on_wizard_finish(self, wizard):
"""
Create the ninja_porject (.nja file), create the main __init__.py
and open the project
"""
ids = wizard.pageIds()
page = wizard.page(ids[1])
name = page.txtName.text()
path = os.path.join(page.txtPlace.text(), name)
if not path:
QMessageBox.critical(self, self.tr("Incorrect Location"),
self.tr("The project couldn\'t be create"))
return
if not os.path.exists(path):
os.makedirs(path)
project = {}
project['name'] = name
project['description'] = page.txtDescription.toPlainText()
project['license'] = page.cboLicense.currentText()
project['venv'] = page.vtxtPlace.text()
json_manager.create_ninja_project(path, name, project)
try:
file_manager.create_init_file(path)
except:
logger.debug("The __init__ file already exists - Import Sources.")
wizard._load_project(path)
示例9: change_log_folder
def change_log_folder(self):
folder = self.explorer_s.get_tree_projects()._get_project_root().path
plugin = json_manager.read_ninja_project(folder)
self.logFolder = QFileDialog.getExistingDirectory(
self, self.tr("Select Log Folder"), plugin["logfolder"])
if self.logFolder != "":
plugin["logfolder"] = self.logFolder
json_manager.create_ninja_project(folder, plugin["name"], plugin)
示例10: save_properties
def save_properties(self):
if unicode(self.projectData.name.text()).strip() == '':
QMessageBox.critical(self, self.tr("Properties Invalid"),
self.tr("The Project must have a name."))
return
tempName = self._item.name
self._item.name = unicode(self.projectData.name.text())
self._item.description = unicode(
self.projectData.description.toPlainText())
self._item.license = unicode(self.projectData.cboLicense.currentText())
self._item.mainFile = unicode(self.projectExecution.path.text())
self._item.url = unicode(self.projectData.url.text())
self._item.projectType = unicode(self.projectData.txtType.text())
self._item.pythonPath = unicode(
self.projectExecution.txtPythonPath.text()) # FIXME
self._item.PYTHONPATH = unicode(
self.projectExecution.PYTHONPATH.toPlainText())
self._item.preExecScript = unicode(
self.projectExecution.txtPreExec.text())
self._item.postExecScript = unicode(
self.projectExecution.txtPostExec.text())
self._item.programParams = unicode(
self.projectExecution.txtParams.text())
self._item.venv = unicode(self.projectExecution.txtVenvPath.text())
extensions = unicode(self.projectData.txtExtensions.text()).split(', ')
self._item.extensions = tuple(extensions)
#save project properties
project = {}
project['name'] = self._item.name
project['description'] = self._item.description
project['url'] = self._item.url
project['license'] = self._item.license
project['mainFile'] = self._item.mainFile
project['project-type'] = self._item.projectType
project['supported-extensions'] = self._item.extensions
project['pythonPath'] = self._item.pythonPath # FIXME
project['PYTHONPATH'] = self._item.PYTHONPATH
project['preExecScript'] = self._item.preExecScript
project['postExecScript'] = self._item.postExecScript
project['venv'] = self._item.venv
project['programParams'] = self._item.programParams
if tempName != self._item.name and \
file_manager.file_exists(self._item.path, tempName + '.nja'):
file_manager.delete_file(self._item.path, tempName + '.nja')
json_manager.create_ninja_project(
self._item.path, self._item.name, project)
self._item.setText(0, self._item.name)
self._item.setToolTip(0, self._item.name)
if self._item.extensions != settings.SUPPORTED_EXTENSIONS:
self._item._parent._refresh_project(self._item)
self.close()
示例11: test_read_ninja_project
def test_read_ninja_project(self):
path = self.tmpdir
project = 'This is My Project'
structure = dict(foo='bar')
structure = read_ninja_project(path)
self.assertEquals(structure, dict())
structure = dict(foo='bar')
create_ninja_project(path, project, structure)
structure = read_ninja_project(path)
assert structure['foo'] == 'bar'
示例12: test_create_ninja_project_with_lot_of_spaces_in_name
def test_create_ninja_project_with_lot_of_spaces_in_name(self):
path = self.tmpdir
project = 'This is My Project '
structure = dict(foo='bar')
create_ninja_project(path, project, structure)
expected_name = 'this_is_my_________project.nja'
self.assertTrue(expected_name in os.listdir(path))
with open(os.path.join(path, expected_name), 'r') as fp:
content = json.load(fp)
assert content['foo'] == 'bar'
示例13: on_wizard_finish
def on_wizard_finish(self, wizard):
"""
Create the ninja_porject (.nja file) and open the project
"""
ids = wizard.pageIds()
page = wizard.page(ids[1])
path = unicode(page.txtPlace.text())
if not path:
QMessageBox.critical(self, self.tr("Incorrect Location"),
self.tr("The project couldn\'t be create"))
return
project = {}
name = unicode(page.txtName.text())
project['name'] = name
project['description'] = unicode(page.txtDescription.toPlainText())
project['license'] = unicode(page.cboLicense.currentText())
project['venv'] = unicode(page.vtxtPlace.text())
json_manager.create_ninja_project(path, name, project)
wizard._load_project(path)
示例14: on_wizard_finish
def on_wizard_finish(self, wizard):
"""
Create the ninja_porject (.nja file) and open the project
"""
ids = wizard.pageIds()
page = wizard.page(ids[1])
name = page.txtName.text()
path = page.txtPlace.text()
if not path:
QMessageBox.critical(self, self.tr("Incorrect Location"), self.tr("The project couldn't be create"))
return
project = {}
project["name"] = name
project["description"] = page.txtDescription.toPlainText()
project["license"] = page.cboLicense.currentText()
project["venv"] = page.vtxtPlace.text()
project["project-type"] = wizard.option
json_manager.create_ninja_project(path, name, project)
wizard._load_project(path)
示例15: on_wizard_finish
def on_wizard_finish(self, wizard):
"""
Create the ninja_porject (.nja file) and open the project
"""
ids = wizard.pageIds()
page = wizard.page(ids[1])
name = page.txtName.text()
path = page.txtPlace.text()
if not path:
QMessageBox.critical(self, _translate("PythonProjectHandler", "Incorrect Location"),
_translate("PythonProjectHandler", "The project couldn\'t be create"))
return
project = {}
project['name'] = name
project['description'] = page.txtDescription.toPlainText()
project['license'] = page.cboLicense.currentText()
project['venv'] = page.vtxtPlace.text()
project['project-type'] = wizard.option
json_manager.create_ninja_project(path, name, project)
wizard._load_project(path)