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


Python json_manager.read_ninja_project函数代码示例

本文整理汇总了Python中ninja_ide.tools.json_manager.read_ninja_project函数的典型用法代码示例。如果您正苦于以下问题:Python read_ninja_project函数的具体用法?Python read_ninja_project怎么用?Python read_ninja_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: 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'
开发者ID:AlexaProjects,项目名称:Alexa2,代码行数:13,代码来源:test_ninja_project.py

示例2: save_recent_projects

    def save_recent_projects(self, folder):
        recent_project_list = QSettings(
            resources.SETTINGS_PATH,
            QSettings.IniFormat).value('recentProjects', {})
        #if already exist on the list update the date time
        projectProperties = json_manager.read_ninja_project(folder)
        name = projectProperties.get('name', '')
        description = projectProperties.get('description', '')

        if name == '':
            name = file_manager.get_basename(folder)

        if description == '':
            description = _translate("_s_ExplorerContainer", 'no description available')

        if folder in recent_project_list:
            properties = recent_project_list[folder]
            properties["lastopen"] = QDateTime.currentDateTime()
            properties["name"] = name
            properties["description"] = description
            recent_project_list[folder] = properties
        else:
            recent_project_list[folder] = {
                "name": name,
                "description": description,
                "isFavorite": False, "lastopen": QDateTime.currentDateTime()}
            #if the length of the project list it's high that 10 then delete
            #the most old
            #TODO: add the length of available projects to setting
            if len(recent_project_list) > 10:
                del recent_project_list[self.find_most_old_open()]
        QSettings(resources.SETTINGS_PATH, QSettings.IniFormat).setValue(
            'recentProjects', recent_project_list)
开发者ID:Salmista-94,项目名称:Ninja_PyQt5,代码行数:33,代码来源:explorer_container.py

示例3: __init__

 def __init__(self, parent, _name, path):
     QTreeWidgetItem.__init__(self, parent)
     self._parent = parent
     self.setText(0, _name)
     self.path = path
     self.isFolder = True
     self.setForeground(0, QBrush(QColor(255, 165, 0)))
     project = json_manager.read_ninja_project(path)
     self.name = project.get('name', '')
     if self.name == '':
         self.name = _name
     self.setText(0, self.name)
     self.projectType = project.get('project-type', '')
     self.description = project.get('description', '')
     self.url = project.get('url', '')
     self.license = project.get('license', '')
     self.mainFile = project.get('mainFile', '')
     self.preExecScript = project.get('preExecScript', '')
     self.postExecScript = project.get('postExecScript', '')
     self.indentation = project.get('indentation', settings.INDENT)
     self.useTabs = project.get('use-tabs', settings.USE_TABS)
     self.extensions = project.get('supported-extensions',
         settings.SUPPORTED_EXTENSIONS)
     self.pythonPath = project.get('pythonPath', settings.PYTHON_PATH)
     self.PYTHONPATH = project.get('PYTHONPATH', '')
     self.programParams = project.get('programParams', '')
     self.venv = project.get('venv', '')
     self.related_projects = project.get('relatedProjects', [])
     self.update_paths()
     self.addedToConsole = False
开发者ID:Bengt,项目名称:ninja-ide,代码行数:30,代码来源:tree_projects_widget.py

示例4: save_recent_projects

    def save_recent_projects(self, folder):
        recent_project_list = QSettings().value('recentProjects', {}).toMap()
        #if already exist on the list update the date time
        projectProperties = json_manager.read_ninja_project(folder)
        name = projectProperties.get('name', '')
        description = projectProperties.get('description', '')

        if name == '':
            name = file_manager.get_basename(folder)

        if description == '':
            description = self.tr('no description available')

        if QString(folder) in recent_project_list:
            properties = recent_project_list[QString(folder)].toMap()
            properties[QString("lastopen")] = QDateTime.currentDateTime()
            properties[QString("name")] = name
            properties[QString("description")] = description
            recent_project_list[QString(folder)] = properties
        else:
            recent_project_list[QString(folder)] = {
                "name": name,
                "description": description,
                "isFavorite": False, "lastopen": QDateTime.currentDateTime()}
            #if the length of the project list it's high that 10 then delete
            #the most old
            #TODO: add the length of available projects to setting
            if len(recent_project_list) > 10:
                del recent_project_list[self.find_most_old_open()]
        QSettings().setValue('recentProjects', recent_project_list)
开发者ID:beefsack,项目名称:ninja-ide,代码行数:30,代码来源:explorer_container.py

示例5: 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

示例6: __init__

 def __init__(self, parent, _name, path):
     QTreeWidgetItem.__init__(self, parent)
     self._parent = parent
     self.setText(0, _name)
     self.path = path
     self.isFolder = True
     self.setForeground(0, QBrush(Qt.darkGray))
     project = json_manager.read_ninja_project(path)
     self.name = project.get('name', '')
     if self.name == '':
         self.name = _name
     self.setText(0, self.name)
     self.projectType = project.get('project-type', '')
     self.description = project.get('description', '')
     self.url = project.get('url', '')
     self.license = project.get('license', '')
     self.mainFile = project.get('mainFile', '')
     self.preExecScript = project.get('preExecScript', '')
     self.postExecScript = project.get('postExecScript', '')
     self.extensions = project.get('supported-extensions',
         settings.SUPPORTED_EXTENSIONS)
     self.pythonPath = project.get('pythonPath', settings.PYTHON_PATH)
     self.programParams = project.get('programParams', '')
     self.venv = project.get('venv', '')
     self.addedToConsole = False
开发者ID:dawee,项目名称:ninja-ide,代码行数:25,代码来源:tree_projects_widget.py

示例7: save_recent_projects

    def save_recent_projects(self, folder):
        settings = IDE.data_settings()
        recent_project_list = settings.value('recentProjects', {})
        #if already exist on the list update the date time
        projectProperties = json_manager.read_ninja_project(folder)
        name = projectProperties.get('name', '')
        description = projectProperties.get('description', '')

        if name == '':
            name = file_manager.get_basename(folder)

        if description == '':
            description = translations.TR_NO_DESCRIPTION

        if folder in recent_project_list:
            properties = recent_project_list[folder]
            properties["lastopen"] = QDateTime.currentDateTime()
            properties["name"] = name
            properties["description"] = description
            recent_project_list[folder] = properties
        else:
            recent_project_list[folder] = {
                "name": name,
                "description": description,
                "isFavorite": False, "lastopen": QDateTime.currentDateTime()}
            #if the length of the project list it's high that 10 then delete
            #the most old
            #TODO: add the length of available projects to setting
            if len(recent_project_list) > 10:
                del recent_project_list[self.find_most_old_open(
                    recent_project_list)]
        settings.setValue('recentProjects', recent_project_list)
开发者ID:LeoYao,项目名称:ninja-ide,代码行数:32,代码来源:tree_projects_widget.py

示例8: open_project_folder

 def open_project_folder(self, folderName='', notIDEStart=True):
     if not self._treeProjects and notIDEStart:
         QMessageBox.information(self, self.tr("Projects Disabled"),
             self.tr("Project support has been disabled from Preferences"))
         return
     if not folderName:
         if settings.WORKSPACE:
             directory = settings.WORKSPACE
         else:
             directory = self._workingDirectory
         folderName = unicode(QFileDialog.getExistingDirectory(self,
             self.tr("Open Project Directory"), directory))
     try:
         if not folderName:
             return
         self._workingDirectory = folderName
         if not self._treeProjects.is_open(folderName):
             project = json_manager.read_ninja_project(folderName)
             extensions = project.get('supported-extensions',
                 settings.SUPPORTED_EXTENSIONS)
             if extensions != settings.SUPPORTED_EXTENSIONS:
                 structure = file_manager.open_project_with_extensions(
                     folderName, extensions)
             else:
                 structure = file_manager.open_project(folderName)
             self._treeProjects.load_project(structure, folderName)
             self.save_recent_projects(folderName)
         else:
             self._treeProjects._set_current_project(folderName)
         self.emit(SIGNAL("projectOpened(QString)"), folderName)
     except Exception, reason:
         logger.error('open_project_folder: %s', reason)
         if not notIDEStart:
             QMessageBox.information(self, self.tr("Incorrect Project"),
                 self.tr("The project could not be loaded!"))
开发者ID:carpincho,项目名称:ninja-ide,代码行数:35,代码来源:explorer_container.py

示例9: __init__

    def __init__(self, path):
        super(NProject, self).__init__()
        project = json_manager.read_ninja_project(path)

        self.path = path
        self._name = project.get('name', '')
        if self._name == '':
            self._name = file_manager.get_basename(path)
        self.project_type = project.get('project-type', '')
        self.description = project.get('description', '')
        if self.description == '':
            self.description = translations.TR_NO_DESCRIPTION
        self.url = project.get('url', '')
        self.license = project.get('license', '')
        self.main_file = project.get('mainFile', '')
        self.pre_exec_script = project.get('preExecScript', '')
        self.post_exec_script = project.get('postExecScript', '')
        self.indentation = project.get('indentation', settings.INDENT)
        self.use_tabs = project.get('use-tabs', settings.USE_TABS)
        self.extensions = project.get('supported-extensions',
            settings.SUPPORTED_EXTENSIONS)
        self.python_exec = project.get('pythonExec', settings.PYTHON_EXEC)
        self.python_path = project.get('PYTHONPATH', '')
        self.additional_builtins = project.get('additional_builtins', [])
        self.program_params = project.get('programParams', '')
        self.venv = project.get('venv', '')
        self.related_projects = project.get('relatedProjects', [])
        self.added_to_console = False
        self.is_current = False
        #Model is a QFileSystemModel to be set on runtime
        self.__model = None
开发者ID:AnyBucket,项目名称:ninja-ide,代码行数:31,代码来源:nproject.py

示例10: save_recent_projects

    def save_recent_projects(self, folder):
        recent_project_list = QSettings().value("recentProjects", {})
        # if already exist on the list update the date time
        projectProperties = json_manager.read_ninja_project(folder)
        name = projectProperties.get("name", "")
        description = projectProperties.get("description", "")

        if name == "":
            name = file_manager.get_basename(folder)

        if description == "":
            description = self.tr("no description available")

        if folder in recent_project_list:
            properties = recent_project_list[folder]
            properties["lastopen"] = QDateTime.currentDateTime()
            properties["name"] = name
            properties["description"] = description
            recent_project_list[folder] = properties
        else:
            recent_project_list[folder] = {
                "name": name,
                "description": description,
                "isFavorite": False,
                "lastopen": QDateTime.currentDateTime(),
            }
            # if the length of the project list it's high that 10 then delete
            # the most old
            # TODO: add the length of available projects to setting
            if len(recent_project_list) > 10:
                del recent_project_list[self.find_most_old_open()]
        QSettings().setValue("recentProjects", recent_project_list)
开发者ID:jamzo,项目名称:ninja-ide,代码行数:32,代码来源:explorer_container.py

示例11: locate_code

    def locate_code(self):
        explorerContainer = explorer_container.ExplorerContainer()
        projects_obj = explorerContainer.get_opened_projects()
        projects = [p.path for p in projects_obj]
        if not projects:
            return
        queue = Queue.Queue()
        for project in projects:
            queue.put(project)
        while not self._cancel and not queue.empty():
            current_dir = QDir(queue.get())
            #Skip not readable dirs!
            if not current_dir.isReadable():
                continue

            project_data = project = json_manager.read_ninja_project(
                current_dir.path())
            extensions = project_data.get('supported-extensions',
                settings.SUPPORTED_EXTENSIONS)

            queue_folders = Queue.Queue()
            queue_folders.put(current_dir)
            self.__locate_code_in_project(queue_folders, extensions)
        self.dirty = True
        self.get_locations()
开发者ID:DevNIX,项目名称:ninja-ide,代码行数:25,代码来源:locator.py

示例12: test_read_ninja_bad_file_project

    def test_read_ninja_bad_file_project(self):

        path = self.tmpdir
        frula_file = os.path.join(path, 'frula.nja')
        with open(frula_file, 'w') as fp:
            fp.write('frula\n')

        structure = read_ninja_project(path)
        assert structure == dict()
开发者ID:AlexaProjects,项目名称:Alexa2,代码行数:9,代码来源:test_ninja_project.py

示例13: 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)
开发者ID:AlexaProjects,项目名称:Alexa2,代码行数:10,代码来源:menu.py

示例14: _thread_open_project

    def _thread_open_project(self):
        try:
            project = json_manager.read_ninja_project(self._folder_path)
            extensions = project.get("supported-extensions", settings.SUPPORTED_EXTENSIONS)
            if extensions != settings.SUPPORTED_EXTENSIONS:
                structure = file_manager.open_project_with_extensions(self._folder_path, extensions)
            else:
                structure = file_manager.open_project(self._folder_path)

            self.emit(SIGNAL("folderDataAcquired(PyQt_PyObject)"), (self._folder_path, structure))
        except:
            self.emit(SIGNAL("folderDataAcquired(PyQt_PyObject)"), (self._folder_path, None))
开发者ID:kennyfm91,项目名称:ninja-ide,代码行数:12,代码来源:ui_tools.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


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