• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python file_manager.get_folder函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _rename_file

    def _rename_file(self):
        item = self.currentItem()
        if item.parent() is None:
            pathForFile = item.path
        else:
            pathForFile = os.path.join(item.path, item.text(0))
        result = QInputDialog.getText(self, self.tr("Rename File"),
            self.tr("Enter New File Name:"), text=item.text(0))
        fileName = result[0]

        if result[1] and fileName.strip() != '':
            fileName = os.path.join(
                file_manager.get_folder(pathForFile), fileName)
            if pathForFile == fileName:
                return
            try:
                fileName = file_manager.rename_file(pathForFile, fileName)
                name = file_manager.get_basename(fileName)
                mainContainer = main_container.MainContainer()
                if mainContainer.is_open(pathForFile):
                    mainContainer.change_open_tab_name(pathForFile, fileName)
                subitem = ProjectItem(item.parent(), name,
                    file_manager.get_folder(fileName))
                subitem.setToolTip(0, name)
                subitem.setIcon(0, self._get_file_icon(name))
                index = item.parent().indexOfChild(item)
                subitem.parent().takeChild(index)
            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,代码行数:31,代码来源:tree_projects_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: 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


示例4: open_file

    def open_file(self, filename='', cursorPosition=-1,
                    tabIndex=None, positionIsLineNumber=False, notStart=True):
        if not filename:
            if settings.WORKSPACE:
                directory = settings.WORKSPACE
            else:
                directory = os.path.expanduser("~")
                editorWidget = self.get_actual_editor()
                pexplorer = self._parent.explorer
                current_project = pexplorer and pexplorer.get_actual_project()
                if current_project is not None:
                    directory = current_project
                elif editorWidget is not None and editorWidget.ID:
                    directory = file_manager.get_folder(editorWidget.ID)
            extensions = ';;'.join(
                ['(*%s)' % e for e in
                    settings.SUPPORTED_EXTENSIONS + ['.*', '']])
            fileNames = list(QFileDialog.getOpenFileNames(self,
                self.tr("Open File"), directory, extensions))
        else:
            fileNames = [filename]
        if not fileNames:
            return

        for filename in fileNames:
            if file_manager.get_file_extension(filename) in ('jpg', 'png'):
                self.open_image(filename)
            elif file_manager.get_file_extension(filename).endswith('ui'):
                self.w = uic.loadUi(filename)
                self.w.show()
            else:
                self.__open_file(filename, cursorPosition,
                    tabIndex, positionIsLineNumber, notStart)
开发者ID:sbellem,项目名称:ninja-ide,代码行数:33,代码来源:main_container.py


示例5: get_item_for_path

 def get_item_for_path(self, path):
     items = self.findItems(file_manager.get_basename(path),
         Qt.MatchRecursive, 0)
     folder = file_manager.get_folder(path)
     for item in items:
         if file_manager.belongs_to_folder(folder, item.path):
             return item
开发者ID:Bengt,项目名称:ninja-ide,代码行数:7,代码来源:tree_projects_widget.py


示例6: open_file

    def open_file(self, filename="", cursorPosition=0, tabIndex=None, positionIsLineNumber=False, notStart=True):
        filename = unicode(filename)
        if not filename:
            if settings.WORKSPACE:
                directory = settings.WORKSPACE
            else:
                directory = os.path.expanduser("~")
                editorWidget = self.get_actual_editor()
                current_project = self._parent.explorer.get_actual_project()
                if current_project is not None:
                    directory = current_project
                elif editorWidget is not None and editorWidget.ID:
                    directory = file_manager.get_folder(editorWidget.ID)
            extensions = ";;".join(["(*%s)" % e for e in settings.SUPPORTED_EXTENSIONS + [".*", ""]])
            fileNames = list(QFileDialog.getOpenFileNames(self, self.tr("Open File"), directory, extensions))
        else:
            fileNames = [filename]
        if not fileNames:
            return

        for filename in fileNames:
            filename = unicode(filename)
            if file_manager.get_file_extension(filename) in ("jpg", "png"):
                self.open_image(filename)
            elif file_manager.get_file_extension(filename).endswith("ui"):
                self.w = uic.loadUi(filename)
                self.w.show()
            else:
                self.__open_file(filename, cursorPosition, tabIndex, positionIsLineNumber, notStart)
开发者ID:mauricioacrueda,项目名称:ninja-ide,代码行数:29,代码来源:main_container.py


示例7: __main_execution

    def __main_execution(self):
        """Execute the project."""
        self.output.setCurrentCharFormat(self.output.plain_format)
        message = ''
        if self.__preScriptExecuted:
            self.__preScriptExecuted = False
            message = self.tr(
                "Pre Execution Script Successfully executed.\n\n")
        self.output.setPlainText(message + 'Running: %s (%s)\n\n' %
            (self.fileName, unicode(time.ctime())))
        self.output.moveCursor(QTextCursor.Down)
        self.output.moveCursor(QTextCursor.Down)
        self.output.moveCursor(QTextCursor.Down)

        #runner.run_code_from_file(fileName)
        if not self.pythonPath:
            self.pythonPath = settings.PYTHON_PATH
        #change the working directory to the fileName dir
        file_directory = file_manager.get_folder(self.fileName)
        self._proc.setWorkingDirectory(file_directory)
        #force python to unbuffer stdin and stdout
        options = ['-u'] + settings.EXECUTION_OPTIONS.split()
        self.currentProcess = self._proc
        self._proc.start(self.pythonPath, options + [self.fileName] + \
            [p.strip() for p in self.programParams.split(',') if p])
开发者ID:b250783,项目名称:ninja-ide,代码行数:25,代码来源:run_widget.py


示例8: open_file

    def open_file(self, filename='', cursorPosition=-1,
                    tabIndex=None, positionIsLineNumber=False, notStart=True):
        if not filename:
            if settings.WORKSPACE:
                directory = settings.WORKSPACE
            else:
                directory = os.path.expanduser("~")
                editorWidget = self.get_actual_editor()
                pexplorer = self._parent.explorer
                current_project = pexplorer and pexplorer.get_actual_project()
                if current_project is not None:
                    directory = current_project
                elif editorWidget is not None and editorWidget.ID:
                    directory = file_manager.get_folder(editorWidget.ID)
            extensions = ';;'.join(
                ['(*%s)' % e for e in
                    settings.SUPPORTED_EXTENSIONS + ['.*', '']])
            fileNames = QFileDialog.getOpenFileNames(self,
                _translate("_s_MainContainer", "Open File"), directory, extensions)[0]#list()
        else:
            fileNames = [filename]
            #print(":::filename:", filename)
        if not fileNames:
            return

        othersFileNames = []
        for filename in fileNames:
            if QFileInfo(filename).isDir():
                othersFileNames.extend( QFileDialog.getOpenFileNames(None,
                    "Select files", filename, "Files (*.*)")[0] )
            elif file_manager.get_file_extension(filename) in ('jpg', 'png'):
                self.open_image(filename)
            elif file_manager.get_file_extension(filename).endswith('ui'):
                self.w = uic.loadUi(filename)
                self.w.show()
            else:
                self.__open_file(filename, cursorPosition,
                    tabIndex, positionIsLineNumber, notStart)

        for filename in othersFileNames:
            print("fileNames:::", filename)
            if QFileInfo(filename).isDir():
                continue
            elif file_manager.get_file_extension(filename) in ('jpg', 'png'):
                self.open_image(filename)
            elif file_manager.get_file_extension(filename).endswith('ui'):
                self.w = uic.loadUi(filename)
                self.w.show()
            else:
                self.__open_file(filename, cursorPosition,
                    tabIndex, positionIsLineNumber, notStart)
开发者ID:Salmista-94,项目名称:Ninja_PyQt5,代码行数:51,代码来源:main_container.py


示例9: add_existing_file

 def add_existing_file(self, path):
     relative = file_manager.convert_to_relative(
         self._actualProject.path, path)
     paths = relative.split(os.sep)[:-1]
     itemParent = self._actualProject
     for p in paths:
         for i in range(itemParent.childCount()):
             item = itemParent.child(i)
             if item.text(0) == p:
                 itemParent = item
                 break
     itemParent.setSelected(True)
     name = file_manager.get_basename(path)
     subitem = ProjectItem(itemParent, name, file_manager.get_folder(path))
     subitem.setToolTip(0, name)
     subitem.setIcon(0, self._get_file_icon(name))
     itemParent.setExpanded(True)
开发者ID:Bengt,项目名称:ninja-ide,代码行数:17,代码来源:tree_projects_widget.py


示例10: open_project_folder

 def open_project_folder(self, folderName='', notIDEStart=True):
     self._treeProjects.mute_signals = 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 = os.path.expanduser("~")
             current_project = self.get_actual_project()
             mainContainer = main_container.MainContainer()
             editorWidget = mainContainer.get_actual_editor()
             if current_project is not None:
                 directory = current_project
             elif editorWidget is not None and editorWidget.ID:
                 directory = file_manager.get_folder(editorWidget.ID)
         folderName = unicode(QFileDialog.getExistingDirectory(self,
             self.tr("Open Project Directory"), directory))
     try:
         if not folderName:
             return
         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:matiexe,项目名称:ninja-ide,代码行数:42,代码来源:explorer_container.py


示例11: start_process

    def start_process(self, fileName, pythonPath=False, programParams=''):
        self.lblInput.show()
        self.input.show()
        self.output.setCurrentCharFormat(self.output.plain_format)
        self.output.setPlainText('Running: %s (%s)\n\n' % (fileName,
            unicode(time.ctime())))
        self.output.moveCursor(QTextCursor.Down)
        self.output.moveCursor(QTextCursor.Down)
        self.output.moveCursor(QTextCursor.Down)

        #runner.run_code_from_file(fileName)
        if not pythonPath:
            pythonPath = settings.PYTHON_PATH
        #change the working directory to the fileName dir
        file_directory = file_manager.get_folder(fileName)
        self._proc.setWorkingDirectory(file_directory)
        #force python to unbuffer stdin and stdout
        options = ['-u'] + settings.EXECUTION_OPTIONS.split()
        self._proc.start(pythonPath, options + [fileName] + \
            [p.strip() for p in programParams.split(',') if p])
开发者ID:sanyaade,项目名称:ninja-ide,代码行数:20,代码来源:run_widget.py


示例12: 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 = os.path.expanduser("~")
             current_project = self.get_actual_project()
             mainContainer = main_container.MainContainer()
             editorWidget = mainContainer.get_actual_editor()
             if current_project is not None:
                 directory = current_project
             elif editorWidget is not None and editorWidget.ID:
                 directory = file_manager.get_folder(editorWidget.ID)
         folderName = QFileDialog.getExistingDirectory(self,
             self.tr("Open Project Directory"), directory)
     try:
         if not folderName:
             return
         if not self._treeProjects.is_open(folderName):
             self._treeProjects.mute_signals = True
             self._treeProjects.loading_project(folderName)
             thread = ui_tools.ThreadProjectExplore()
             self._thread_execution[folderName] = thread
             self.connect(thread,
                 SIGNAL("folderDataAcquired(PyQt_PyObject)"),
                 self._callback_open_project)
             self.connect(thread,
                 SIGNAL("finished()"),
                 self._unmute_tree_signals_clean_threads)
             thread.open_folder(folderName)
         else:
             self._treeProjects._set_current_project(folderName)
     except Exception as 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:MatthewWest,项目名称:ninja-ide,代码行数:41,代码来源:explorer_container.py


示例13: __main_execution

    def __main_execution(self):
        """Execute the project."""
        self.output.setCurrentCharFormat(self.output.plain_format)
        message = ''
        if self.__preScriptExecuted:
            self.__preScriptExecuted = False
            message = self.tr(
                "Pre Execution Script Successfully executed.\n\n")
        self.output.setPlainText(message + 'Running: %s (%s)\n\n' %
            (self.fileName, time.ctime()))
        self.output.moveCursor(QTextCursor.Down)
        self.output.moveCursor(QTextCursor.Down)
        self.output.moveCursor(QTextCursor.Down)

        #runner.run_code_from_file(fileName)
        if not self.pythonPath:
            self.pythonPath = settings.PYTHON_PATH
        #change the working directory to the fileName dir
        file_directory = file_manager.get_folder(self.fileName)
        self._proc.setWorkingDirectory(file_directory)
        #force python to unbuffer stdin and stdout
        options = ['-u'] + settings.EXECUTION_OPTIONS.split()
        self.currentProcess = self._proc

        env = QProcessEnvironment()
        system_environemnt = self._proc.systemEnvironment()
        for e in system_environemnt:
            key, value = e.split('=', 1)
            env.insert(key, value)
        if self.PYTHONPATH:
            envpaths = [path for path in self.PYTHONPATH.splitlines()]
            for path in envpaths:
                env.insert('PYTHONPATH', path)
        env.insert('PYTHONIOENCODING', 'utf-8')
        self._proc.setProcessEnvironment(env)

        self._proc.start(self.pythonPath, options + [self.fileName] +
            [p.strip() for p in self.programParams.split(',') if p])
开发者ID:DevNIX,项目名称:ninja-ide,代码行数:38,代码来源:run_widget.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python file_manager.read_file_content函数代码示例发布时间:2022-05-27
下一篇:
Python file_manager.get_file_extension函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap