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

Python settings.get_symbols_handler函数代码示例

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

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



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

示例1: get_symbols_for_class

 def get_symbols_for_class(self, file_path, clazzName):
     lines = []
     with open(file_path) as f:
         content = f.read()
         ext = file_manager.get_file_extension(file_path)
         #obtain a symbols handler for this file extension
         symbols_handler = settings.get_symbols_handler(ext)
         symbols = symbols_handler.obtain_symbols(content)
         if "classes" in symbols:
             for claz in symbols['classes']:
                 if claz != clazzName:
                     continue
                 clazz = symbols['classes'][claz]
                 #type - class name - file_path - lineNumber
                 lines.append(('<', claz, unicode(file_path),
                     clazz[0] - 1))
                 if 'attributes' in clazz[1]:
                     for attr in clazz[1]['attributes']:
                         #type - attribute name - file_path - lineNumber
                         lines.append(('-', attr, unicode(file_path),
                             clazz[1]['attributes'][attr] - 1))
                 if 'functions' in clazz[1]:
                     for func in clazz[1]['functions']:
                         #type - function name - file_path - lineNumber
                         lines.append(('>', func, unicode(file_path),
                             clazz[1]['functions'][func] - 1))
                 return lines
         return []
开发者ID:Fieldbyte,项目名称:ninja-ide,代码行数:28,代码来源:locator.py


示例2: update_explorer

    def update_explorer(self):
        """Update the symbols in the Symbol Explorer when a file is saved."""
        main_container = IDE.get_service('main_container')
        if not main_container:
            return
        editorWidget = main_container.get_current_editor()
        if editorWidget:
            ext = file_manager.get_file_extension(editorWidget.ID)
            #obtain a symbols handler for this file extension
            symbols_handler = settings.get_symbols_handler(ext)
            if symbols_handler:
                source = editorWidget.toPlainText()
                if editorWidget.encoding is not None:
                    source = source.encode(editorWidget.encoding)
                if ext == 'py':
                    args = (source, True)
                else:
                    args = (source,)
                symbols = symbols_handler.obtain_symbols(*args)
                self.update_symbols(symbols, editorWidget.ID)

            #TODO: Should we change the code below similar to the code above?
            exts = settings.SYNTAX.get('python')['extension']
            if ext in exts or editorWidget.newDocument:
                self.update_errors(editorWidget.errors, editorWidget.pep8)
开发者ID:jsargiot,项目名称:ninja-ide,代码行数:25,代码来源:explorer_container.py


示例3: get_symbols_for_class

 def get_symbols_for_class(self, file_path, clazzName):
     lines = []
     with open(file_path) as f:
         content = f.read()
         ext = file_manager.get_file_extension(file_path)
         #obtain a symbols handler for this file extension
         symbols_handler = settings.get_symbols_handler(ext)
         symbols = symbols_handler.obtain_symbols(content,
             filename=file_path)
         if "classes" in symbols:
             for claz in symbols['classes']:
                 if claz != clazzName:
                     continue
                 clazz = symbols['classes'][claz]
                 line_number = clazz[0] - 1
                 lines.append(ResultItem(type=FILTERS['classes'], name=claz,
                     path=file_path, lineno=line_number))
                 if 'attributes' in clazz[1]:
                     for attr in clazz[1]['attributes']:
                         line_number = clazz[1]['attributes'][attr] - 1
                         lines.append(ResultItem(
                             type=FILTERS['attribs'], name=attr,
                             path=file_path, lineno=line_number))
                 if 'functions' in clazz[1]:
                     for func in clazz[1]['functions']:
                         line_number = clazz[1]['functions'][func][0] - 1
                         lines.append(ResultItem(type=FILTERS['functions'],
                             name=func, path=file_path,
                             lineno=line_number))
                 return lines
         return []
开发者ID:DevNIX,项目名称:ninja-ide,代码行数:31,代码来源:locator.py


示例4: _grep_file_locate

    def _grep_file_locate(self, file_path, file_name):
        #type - file_name - file_path
        global mapping_locations
        #TODO: Check if the last know state of the file is valid and load that
        exts = settings.SYNTAX.get('python')['extension']
        file_ext = file_manager.get_file_extension(file_path)
        if file_ext not in exts:
            mapping_locations[file_path] = [
                ResultItem(type=FILTERS['non-python'], name=file_name,
                    path=file_path, lineno=0)]
        else:
            mapping_locations[file_path] = [
                ResultItem(type=FILTERS['files'], name=file_name,
                        path=file_path, lineno=0)]
        #obtain a symbols handler for this file extension
        symbols_handler = settings.get_symbols_handler(file_ext)
        if symbols_handler is None:
            return
        results = []
        with open(file_path) as f:
            content = f.read()
            symbols = symbols_handler.obtain_symbols(content,
                filename=file_path)
            self.__parse_symbols(symbols, results, file_path)

        if results:
            mapping_locations[file_path] += results
开发者ID:jsargiot,项目名称:ninja-ide,代码行数:27,代码来源:locator.py


示例5: _load_symbols

 def _load_symbols(self, neditable):
     symbols_handler = settings.get_symbols_handler('py')
     source = neditable.editor.toPlainText()
     source = source.encode(neditable.editor.encoding)
     symbols = symbols_handler.get_symbols_simplified(source)
     self._symbols_index = sorted(symbols.keys())
     symbols = sorted(list(symbols.items()), key=lambda x: x[0])
     self.bar.add_symbols(symbols)
     line = neditable.editor.textCursor().blockNumber()
     self._set_current_symbol(line, True)
开发者ID:Zekom,项目名称:ninja-ide,代码行数:10,代码来源:combo_editor.py


示例6: _grep_file_locate

 def _grep_file_locate(self, file_path, file_name):
     #type - file_name - file_path
     global mapping_locations
     exts = settings.SYNTAX.get('python')['extension']
     if file_manager.get_file_extension(unicode(file_name)) not in exts:
         mapping_locations[unicode(file_path)] = [
             ResultItem(type=FILTERS['non-python'], name=unicode(file_name),
                 path=unicode(file_path), lineno=0)]
     else:
         mapping_locations[unicode(file_path)] = [
             ResultItem(type=FILTERS['files'], name=unicode(file_name),
                     path=unicode(file_path), lineno=0)]
     ext = file_manager.get_file_extension(file_path)
     #obtain a symbols handler for this file extension
     symbols_handler = settings.get_symbols_handler(ext)
     if symbols_handler is None:
         return
     results = []
     with open(file_path) as f:
         content = f.read()
         symbols = symbols_handler.obtain_symbols(content,
             filename=file_path)
         if "classes" in symbols:
             for claz in symbols['classes']:
                 line_number = symbols['classes'][claz][0] - 1
                 members = symbols['classes'][claz][1]
                 results.append(ResultItem(type=FILTERS['classes'],
                     name=claz, path=unicode(file_path),
                     lineno=line_number))
                 if 'attributes' in members:
                     for attr in members['attributes']:
                         line_number = members['attributes'][attr] - 1
                         results.append(ResultItem(type=FILTERS['attribs'],
                             name=attr, path=unicode(file_path),
                             lineno=line_number))
                 if 'functions' in members:
                     for func in members['functions']:
                         line_number = members['functions'][func] - 1
                         results.append(ResultItem(
                             type=FILTERS['functions'], name=func,
                             path=unicode(file_path), lineno=line_number))
         if 'attributes' in symbols:
             for attr in symbols['attributes']:
                 line_number = symbols['attributes'][attr] - 1
                 results.append(ResultItem(type=FILTERS['attribs'],
                     name=attr, path=unicode(file_path),
                     lineno=line_number))
         if 'functions' in symbols:
             for func in symbols['functions']:
                 line_number = symbols['functions'][func] - 1
                 results.append(ResultItem(
                     type=FILTERS['functions'], name=func,
                     path=unicode(file_path), lineno=line_number))
     if results:
         mapping_locations[unicode(file_path)] += results
开发者ID:uKev,项目名称:ninja-ide,代码行数:55,代码来源:locator.py


示例7: get_symbols_for_class

 def get_symbols_for_class(self, file_path, clazzName):
     results = []
     with open(file_path) as f:
         content = f.read()
         ext = file_manager.get_file_extension(file_path)
         #obtain a symbols handler for this file extension
         symbols_handler = settings.get_symbols_handler(ext)
         symbols = symbols_handler.obtain_symbols(content,
             filename=file_path)
         self.__parse_symbols(symbols, results, file_path)
     return results
开发者ID:jsargiot,项目名称:ninja-ide,代码行数:11,代码来源:locator.py


示例8: _load_symbols

 def _load_symbols(self, neditable):
     symbols_handler = settings.get_symbols_handler('py')
     source = neditable.editor.toPlainText()
     source = source.encode(neditable.editor.encoding)
     symbols, symbols_simplified = symbols_handler.obtain_symbols(
         source, simple=True)
     self._symbols_index = sorted(symbols_simplified.keys())
     symbols_simplified = sorted(
         list(symbols_simplified.items()), key=lambda x: x[0])
     self.bar.add_symbols(symbols_simplified)
     line = neditable.editor.textCursor().blockNumber()
     self._set_current_symbol(line, True)
     tree_symbols = IDE.get_service('symbols_explorer')
     tree_symbols.update_symbols_tree(symbols, neditable.file_path)
开发者ID:WeAreLaVelle,项目名称:ninja-ide,代码行数:14,代码来源:combo_editor.py


示例9: update_explorer

    def update_explorer(self):
        editorWidget = self.ide.mainContainer.get_actual_editor()
        if editorWidget:
            ext = file_manager.get_file_extension(editorWidget.ID)
            #obtain a symbols handler for this file extension
            symbols_handler = settings.get_symbols_handler(ext)
            if symbols_handler:
                source = unicode(editorWidget.toPlainText())
                symbols = symbols_handler.obtain_symbols(source)
                self.ide.explorer.update_symbols(symbols, editorWidget.ID)

            #TODO: Should we change the code below similar to the code above?
            if ext == 'py' or editorWidget.newDocument:
                self.ide.explorer.update_errors(
                    editorWidget.errors, editorWidget.pep8)
开发者ID:sanyaade,项目名称:ninja-ide,代码行数:15,代码来源:actions.py


示例10: _grep_file_locate

    def _grep_file_locate(self, file_path, file_name):
        #type - file_name - file_path
        global mapping_locations
        if file_manager.get_file_extension(unicode(file_name)) != 'py':
            mapping_locations[unicode(file_path)] = [('!',
                unicode(file_name), unicode(file_path), 0)]
            return
        mapping_locations[unicode(file_path)] = [('@', unicode(file_name),
            unicode(file_path), 0)]

        lines = []
        with open(file_path) as f:
            content = f.read()
            ext = file_manager.get_file_extension(file_path)
            #obtain a symbols handler for this file extension
            symbols_handler = settings.get_symbols_handler(ext)
            symbols = symbols_handler.obtain_symbols(content)
            if "classes" in symbols:
                for claz in symbols['classes']:
                    clazz = symbols['classes'][claz]
                    #type - class name - file_path - lineNumber
                    lines.append(('<', claz, unicode(file_path),
                        clazz[0] - 1))
                    if 'attributes' in clazz[1]:
                        for attr in clazz[1]['attributes']:
                            #type - attribute name - file_path - lineNumber
                            lines.append(('-', attr, unicode(file_path),
                                clazz[1]['attributes'][attr] - 1))
                    if 'functions' in clazz[1]:
                        for func in clazz[1]['functions']:
                            #type - function name - file_path - lineNumber
                            lines.append(('>', func, unicode(file_path),
                                clazz[1]['functions'][func] - 1))
            if 'attributes' in symbols:
                for attr in symbols['attributes']:
                    #type - attribute name - file_path - lineNumber
                    lines.append(('-', attr, unicode(file_path),
                        symbols['attributes'][attr] - 1))
            if 'functions' in symbols:
                for func in symbols['functions']:
                    #type - function name - file_path - lineNumber
                    lines.append(('>', func, unicode(file_path),
                        symbols['functions'][func] - 1))
        if lines:
            mapping_locations[unicode(file_path)] += lines
开发者ID:Fieldbyte,项目名称:ninja-ide,代码行数:45,代码来源:locator.py


示例11: update_explorer

    def update_explorer(self):
        """Update the symbols in the Symbol Explorer when a file is saved."""
        editorWidget = self.ide.mainContainer.get_actual_editor()
        if editorWidget:
            ext = file_manager.get_file_extension(editorWidget.ID)
            #obtain a symbols handler for this file extension
            symbols_handler = settings.get_symbols_handler(ext)
            if symbols_handler:
                source = unicode(editorWidget.toPlainText())
                if editorWidget.encoding is not None:
                    source = source.encode(editorWidget.encoding)
                symbols = symbols_handler.obtain_symbols(source)
                self.ide.explorer.update_symbols(symbols, editorWidget.ID)

            #TODO: Should we change the code below similar to the code above?
            exts = settings.SYNTAX.get('python')['extension']
            if ext in exts or editorWidget.newDocument:
                self.ide.explorer.update_errors(
                    editorWidget.errors, editorWidget.pep8)
开发者ID:b250783,项目名称:ninja-ide,代码行数:19,代码来源:actions.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python editor.create_editor函数代码示例发布时间:2022-05-27
下一篇:
Python file_manager.store_file_content函数代码示例发布时间: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