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


Python Paths.getLibraryFolders方法代码示例

本文整理汇总了Python中libs.Paths.getLibraryFolders方法的典型用法代码示例。如果您正苦于以下问题:Python Paths.getLibraryFolders方法的具体用法?Python Paths.getLibraryFolders怎么用?Python Paths.getLibraryFolders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libs.Paths的用法示例。


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

示例1: createLibraryExamplesMenu

# 需要导入模块: from libs import Paths [as 别名]
# 或者: from libs.Paths import getLibraryFolders [as 别名]
    def createLibraryExamplesMenu(self):
        """
        Shows the examples of the library in a menu
        """
        examples = []
        children = []

        library_paths = Paths.getLibraryFolders()
        for path in library_paths:
            sub_paths = glob.glob(path)
            for sub in sub_paths:
                sub = os.path.join(sub, '*')
                libs = glob.glob(sub)
                for lib in libs:
                    caption = os.path.basename(os.path.dirname(lib))
                    new_caption = search(r"^(\w+)_ID?", caption)
                    if(new_caption is not None):
                        caption = new_caption.group(1)
                    if os.path.isdir(lib) and os.listdir(lib) and 'examples' in lib:
                        file_examples = os.path.join(lib, '*')
                        file_examples = glob.glob(file_examples)
                        for file in file_examples:
                            caption_example = os.path.basename(file)
                            temp_info = {}
                            temp_info['caption'] = caption_example
                            temp_info['command'] = 'open_example'
                            temp_info['args'] = {'example_path': file}
                            children.append(temp_info)
                        temp_info = {}
                        temp_info['caption'] = caption
                        temp_info['children'] = children
                        examples.append(temp_info)
                        children = []
            examples.append({'caption': '-'})

        # get preset
        menu_lib_example = self.getTemplateMenu(file_name='examples.json')

        # save file
        menu_lib_example[0]['children'][0]['children'] = examples
        self.saveSublimeMenu(data=menu_lib_example,
                             sub_folder='library_example',
                             user_path=True)
开发者ID:goolic,项目名称:Deviot,代码行数:45,代码来源:Menu.py

示例2: getKeywords

# 需要导入模块: from libs import Paths [as 别名]
# 或者: from libs.Paths import getLibraryFolders [as 别名]
def getKeywords():
    """
    Gets the keywords from the installed libraries

    Returns:
        [list] -- list of object with the keywords
    """
    try:
        from . import Paths
    except:
        from libs import Paths

    keywords = []
    keywords_dirs = Paths.getLibraryFolders()

    for path in keywords_dirs:
        sub_dirs = glob.glob(path)
        for sub_dir in sub_dirs:
            key_file = os.path.join(sub_dir, 'keywords.txt')
            if(os.path.isfile(key_file)):
                keywords.append(Keywords.KeywordsFile(key_file))
    return keywords
开发者ID:BadgerAAV,项目名称:Deviot,代码行数:24,代码来源:Tools.py

示例3: createLibraryImportMenu

# 需要导入模块: from libs import Paths [as 别名]
# 或者: from libs.Paths import getLibraryFolders [as 别名]
    def createLibraryImportMenu(self):
        """
        Creates the import library menu
        this method search in the user and core libraries
        """
        library_paths = Paths.getLibraryFolders()
        added_lib = []
        children = []

        # get preset
        menu_import_lib = self.getTemplateMenu(file_name='import_library.json')

        for library_dir in library_paths:
            # add separator
            if 'arduinoteensy' not in library_dir:
                temp_info = {}
                temp_info['caption'] = '-'
                children.append(temp_info)
            sub_path = glob.glob(library_dir)

            # search in sub path
            for library in sub_path:

                # Add core libraries
                if '__cores__' in library:
                    core_subs = os.path.join(library, '*')
                    core_subs = glob.glob(core_subs)
                    for core_sub in core_subs:
                        core_sub_subs = os.path.join(core_sub, '*')
                        core_sub_subs = glob.glob(core_sub_subs)
                        for core_lib in core_sub_subs:
                            caption = os.path.basename(core_lib)
                            if caption not in added_lib:
                                temp_info = {}
                                temp_info['caption'] = caption
                                temp_info['command'] = 'add_library'
                                temp_info['args'] = {'library_path': library}
                                children.append(temp_info)
                                added_lib.append(caption)

                # the rest of the libraries
                caption = os.path.basename(library)

                # get library name from json file
                pio_libs = os.path.join('platformio', 'lib')
                if pio_libs in library:

                    # get library json details
                    library_json = os.path.join(library, 'library.json')
                    if (os.path.exists(library_json) == False):
                        library_json = os.path.join(library, 'library.properties')

                    # when there´s json content, read it
                    json = JSONFile(library_json)
                    json = json.getData()
                    if (json != {} ):
                        caption = json['name']

                if caption not in added_lib and '__cores__' not in caption:
                    temp_info = {}
                    temp_info['caption'] = caption
                    temp_info['command'] = 'add_library'
                    temp_info['args'] = {'library_path': library}
                    children.append(temp_info)
                    added_lib.append(caption)

        # save file
        menu_import_lib[0]['children'][0]['children'] = children
        self.saveSublimeMenu(data=menu_import_lib,
                             sub_folder='import_library',
                             user_path=True)
开发者ID:goolic,项目名称:Deviot,代码行数:73,代码来源:Menu.py


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