示例#1
0
文件: Install.py 项目: ikthap/Deviot
    def endSetup(self):
        # get pio version
        executable = os.path.join(self.env_bin_dir, 'pio')
        cmd = ['\"' + executable + '\"', '--version']
        out = childProcess(cmd)

        pio_version = match(r"\w+\W \w+ (.+)", out[1]).group(1)
        self.Preferences.set('pio_version', pio_version)

        # save env paths
        env_path = [self.env_bin_dir]
        self.saveEnvPaths(env_path)

        # copy menu
        sys_os = Tools.getOsName()
        preset_path = Paths.getPresetPath()
        plg_path = Paths.getPluginPath()
        dst = os.path.join(plg_path, 'Settings-Default', 'Main.sublime-menu')

        if(sys_os == 'windows'):
            src_path = os.path.join(preset_path, 'Main.sublime-menu.windows')
            copy(src_path, dst)
        elif(sys_os == 'osx'):
            src_path = os.path.join(preset_path, 'Main.sublime-menu.osx')
            copy(src_path, dst)
        else:
            src_path = os.path.join(preset_path, 'Main.sublime-menu.linux')
            copy(src_path, dst)

        # creating files (menu, completions, syntax)
        generateFiles()
示例#2
0
文件: I18n.py 项目: margyle/Deviot
    def listIds(self):
        language_list_path = Paths.getLanguageList()
        self.lang_params = JSONFile(language_list_path).getData()
        language_path = Paths.getLanguagePath()

        lang_file_paths = glob.glob(language_path + '/*.lang')
        lang_file_names = [os.path.basename(p) for p in lang_file_paths]
        self.ids_lang += [os.path.splitext(nam)[0] for nam in lang_file_names]
        self.id_path_dict.update(dict(zip(self.ids_lang, lang_file_paths)))
        self.ids_lang.sort(key=lambda _id: self.lang_params.get(_id)[1])
示例#3
0
文件: I18n.py 项目: BadgerAAV/Deviot
    def listIds(self):
        language_list_path = Paths.getLanguageList()
        self.lang_params = JSONFile(language_list_path).getData()
        language_path = Paths.getLanguagePath()

        lang_file_paths = glob.glob(language_path + '/*.lang')
        lang_file_names = [os.path.basename(p) for p in lang_file_paths]
        self.ids_lang += [os.path.splitext(nam)[0] for nam in lang_file_names]
        self.id_path_dict.update(dict(zip(self.ids_lang, lang_file_paths)))
        self.ids_lang.sort(key=lambda _id: self.lang_params.get(_id)[1])
示例#4
0
文件: Tools.py 项目: BadgerAAV/Deviot
def createSyntaxFile():
    """
    Generate the syntax file based in the installed libraries
    """
    try:
        from . import Paths
        from .JSONFile import JSONFile
    except:
        from libs import Paths
        from libs.JSONFile import JSONFile

    keywords = getKeywords()

    LITERAL1s = []
    KEYWORD1s = []
    KEYWORD2s = []
    KEYWORD3s = []

    # set keywords
    for k in keywords:
        for w in k.get_keywords():
            if 'LITERAL1' in w.get_type():
                LITERAL1s.append(w.get_id())
            if 'KEYWORD1' in w.get_type():
                KEYWORD1s.append(w.get_id())
            if 'KEYWORD2' in w.get_type():
                KEYWORD2s.append(w.get_id())
            if 'KEYWORD3' in w.get_type():
                KEYWORD3s.append(w.get_id())

    # formating
    LITERAL1s = set(LITERAL1s)
    LITERAL1s = '|'.join(LITERAL1s)
    KEYWORD1s = set(KEYWORD1s)
    KEYWORD1s = '|'.join(KEYWORD1s)
    KEYWORD2s = set(KEYWORD2s)
    KEYWORD2s = '|'.join(KEYWORD2s)
    KEYWORD3s = set(KEYWORD3s)
    KEYWORD3s = '|'.join(KEYWORD3s)

    # get sintax preset
    sintax_path = Paths.getSyntaxPath()
    sintax_file = JSONFile(sintax_path)
    sintax = sintax_file.readFile()

    # replace words in sintax file
    sintax = sintax.replace('${LITERAL1}', LITERAL1s)
    sintax = sintax.replace('${KEYWORD1}', KEYWORD1s)
    sintax = sintax.replace('${KEYWORD2}', KEYWORD2s)
    sintax = sintax.replace('${KEYWORD3}', KEYWORD3s)

    # Save File
    file_path = Paths.getTmLanguage()
    language_file = JSONFile(file_path)
    language_file.writeFile(sintax)
示例#5
0
文件: Tools.py 项目: margyle/Deviot
def createSyntaxFile():
    """
    Generate the syntax file based in the installed libraries
    """
    try:
        from . import Paths
        from .JSONFile import JSONFile
    except:
        from libs import Paths
        from libs.JSONFile import JSONFile

    keywords = getKeywords()

    LITERAL1s = []
    KEYWORD1s = []
    KEYWORD2s = []
    KEYWORD3s = []

    # set keywords
    for k in keywords:
        for w in k.get_keywords():
            if 'LITERAL1' in w.get_type():
                LITERAL1s.append(w.get_id())
            if 'KEYWORD1' in w.get_type():
                KEYWORD1s.append(w.get_id())
            if 'KEYWORD2' in w.get_type():
                KEYWORD2s.append(w.get_id())
            if 'KEYWORD3' in w.get_type():
                KEYWORD3s.append(w.get_id())

    # formating
    LITERAL1s = set(LITERAL1s)
    LITERAL1s = '|'.join(LITERAL1s)
    KEYWORD1s = set(KEYWORD1s)
    KEYWORD1s = '|'.join(KEYWORD1s)
    KEYWORD2s = set(KEYWORD2s)
    KEYWORD2s = '|'.join(KEYWORD2s)
    KEYWORD3s = set(KEYWORD3s)
    KEYWORD3s = '|'.join(KEYWORD3s)

    # get sintax preset
    sintax_path = Paths.getSyntaxPath()
    sintax_file = JSONFile(sintax_path)
    sintax = sintax_file.readFile()

    # replace words in sintax file
    sintax = sintax.replace('${LITERAL1}', LITERAL1s)
    sintax = sintax.replace('${KEYWORD1}', KEYWORD1s)
    sintax = sintax.replace('${KEYWORD2}', KEYWORD2s)
    sintax = sintax.replace('${KEYWORD3}', KEYWORD3s)

    # Save File
    file_path = Paths.getTmLanguage()
    language_file = JSONFile(file_path)
    language_file.writeFile(sintax)
示例#6
0
    def saveCodeInFile(self, view):
        """
        If the sketch in the current view has been not saved, it generate
        a random name and stores in a temp folder.

        Arguments: view {ST Object} -- Object with multiples options of ST
        """
        ext = '.ino'

        tmp_path = Paths.getTempPath()
        file_name = str(time.time()).split('.')[0]
        file_path = os.path.join(tmp_path, file_name)
        file_path = os.path.join(file_path, 'src')
        os.makedirs(file_path)

        full_path = file_name + ext
        full_path = os.path.join(file_path, full_path)

        region = sublime.Region(0, view.size())
        text = view.substr(region)
        file = JSONFile(full_path)
        file.writeFile(text)

        view.set_scratch(True)
        window = view.window()
        window.run_command('close')
        view = window.open_file(full_path)

        return (True, view)
示例#7
0
    def initSketchProject(self, chosen):
        '''
        command to initialize the board(s) selected by the user. This
        function can only be use if the workig file is an IoT type
        (checked by isIOTFile)
        '''
        # check if it was already initialized
        ini_path = Paths.getFullIniPath(self.dir)
        if (os.path.isfile(ini_path)):
            with open(ini_path) as file:
                if (chosen in file.read()):
                    return

        init_board = '--board=%s ' % chosen

        if (not init_board):
            current_time = time.strftime('%H:%M:%S')
            msg = 'none_board_sel_{0}'
            self.message_queue.put(msg, current_time)
            self.Commands.error_running = True
            return

        command = ['init', '%s' % (init_board)]

        self.Commands.runCommand(command)

        if (not self.Commands.error_running):
            if (self.is_native):
                self.Preferences.set('init_queue', '')
            if (not self.is_native and self.src):
                self.overrideSrc(self.dir, self.src)
示例#8
0
    def removeEnvFromFile(self, env):
        """
        Removes the environment select from the platformio.ini file

        Arguments:
            env {string} -- environment to remove
        """
        ini_path = self.Preferences.get('ini_path', False)
        if(not ini_path):
            return

        found = False
        write = False
        buffer = ""

        # exclude environment selected
        ini_path = Paths.getFullIniPath(ini_path)
        if(not os.path.isfile(ini_path)):
            return

        with open(ini_path) as file:
            for line in file:
                if(env in line and not found):
                    found = True
                    write = True
                if(not found):
                    buffer += line
                if(found and line == '\n'):
                    found = False

        # save new platformio.ini
        if(write):
            with open(ini_path, 'w') as file:
                file.write(buffer)
示例#9
0
文件: Install.py 项目: ikthap/Deviot
    def __init__(self):
        self.Preferences = Preferences()
        self.base_dir = Paths.getDeviotUserPath()
        self.env_dir = Paths.getEnvDir()
        self.env_bin_dir = Paths.getEnvBinDir()
        self.cache_dir = Paths.getCacheDir()
        self.env_file = Paths.getEnvFile()
        self.cached_file = False

        # console
        window = sublime.active_window()
        console_name = 'Deviot|Pio_Install' + str(time.time())
        console = Messages.Console(window, name=console_name)

        # Queue for the user console
        self.message_queue = Messages.MessageQueue(console)
示例#10
0
    def initSketchProject(self, chosen):
        '''
        command to initialize the board(s) selected by the user. This
        function can only be use if the workig file is an IoT type
        (checked by isIOTFile)
        '''
        # check if it was already initialized
        ini_path = Paths.getFullIniPath(self.dir)
        if(os.path.isfile(ini_path)):
            with open(ini_path) as file:
                if(chosen in file.read()):
                    return

        init_board = '--board=%s ' % chosen

        if(not init_board):
            current_time = time.strftime('%H:%M:%S')
            msg = 'none_board_sel_{0}'
            self.message_queue.put(msg, current_time)
            self.Commands.error_running = True
            return

        command = ['init', '%s' % (init_board)]

        self.Commands.runCommand(command)

        if(not self.Commands.error_running):
            if(self.is_native):
                self.Preferences.set('init_queue', '')
            if(not self.is_native and self.src):
                self.overrideSrc(self.dir, self.src)
示例#11
0
文件: Tools.py 项目: margyle/Deviot
def removePreferences():
    from shutil import rmtree
    try:
        from . import Paths
    except:
        from libs import Paths

    plug_path = Paths.getPluginPath()
    dst = os.path.join(plug_path, 'Settings-Default', 'Main.sublime-menu')
    user_path = Paths.getDeviotUserPath()
    main_menu = Paths.getSublimeMenuPath()

    # remove files
    rmtree(user_path, ignore_errors=False)
    os.remove(main_menu)
    os.remove(dst)
示例#12
0
文件: Tools.py 项目: BadgerAAV/Deviot
def removePreferences():
    from shutil import rmtree
    try:
        from . import Paths
    except:
        from libs import Paths

    plug_path = Paths.getPluginPath()
    dst = os.path.join(plug_path, 'Settings-Default', 'Main.sublime-menu')
    user_path = Paths.getDeviotUserPath()
    main_menu = Paths.getSublimeMenuPath()

    # remove files
    rmtree(user_path, ignore_errors=False)
    os.remove(main_menu)
    os.remove(dst)
示例#13
0
    def saveCodeInFile(self, view):
        """
        If the sketch in the current view has been not saved, it generate
        a random name and stores in a temp folder.

        Arguments: view {ST Object} -- Object with multiples options of ST
        """
        ext = '.ino'

        tmp_path = Paths.getTempPath()
        file_name = str(time.time()).split('.')[0]
        file_path = os.path.join(tmp_path, file_name)
        file_path = os.path.join(file_path, 'src')
        os.makedirs(file_path)

        full_path = file_name + ext
        full_path = os.path.join(file_path, full_path)

        region = sublime.Region(0, view.size())
        text = view.substr(region)
        file = JSONFile(full_path)
        file.writeFile(text)

        view.set_scratch(True)
        window = view.window()
        window.run_command('close')
        view = window.open_file(full_path)

        return (True, view)
示例#14
0
    def removeEnvFromFile(self, env):
        """
        Removes the environment select from the platformio.ini file

        Arguments:
            env {string} -- environment to remove
        """
        ini_path = self.Preferences.get('ini_path', False)
        if (not ini_path):
            return

        found = False
        write = False
        buffer = ""

        # exclude environment selected
        ini_path = Paths.getFullIniPath(ini_path)
        if (not os.path.isfile(ini_path)):
            return

        with open(ini_path) as file:
            for line in file:
                if (env in line and not found):
                    found = True
                    write = True
                if (not found):
                    buffer += line
                if (found and line == '\n'):
                    found = False

        # save new platformio.ini
        if (write):
            with open(ini_path, 'w') as file:
                file.write(buffer)
示例#15
0
文件: Tools.py 项目: margyle/Deviot
def createCompletions():
    """
    Generate the completions file
    """
    try:
        from . import Paths
        from .JSONFile import JSONFile
    except:
        from libs import Paths
        from libs.JSONFile import JSONFile

    keywords = getKeywords()
    keyword_ids = []
    user_path = Paths.getDeviotUserPath()
    completion_path = os.path.join(user_path, 'Deviot.sublime-completions')

    cpp_keywords = ['define', 'error', 'include', 'elif', 'endif']
    cpp_keywords += ['ifdef', 'ifndef', 'undef', 'line', 'pragma']

    for k in keywords:
        for w in k.get_keywords():
            keyword_ids += [w.get_id() for w in k.get_keywords()]

    keyword_ids = set(keyword_ids)
    keyword_ids = [word for word in keyword_ids]

    completions_dict = {'scope': 'source.iot'}
    completions_dict['completions'] = keyword_ids

    file = JSONFile(completion_path)
    file.setData(completions_dict)
示例#16
0
文件: Tools.py 项目: BadgerAAV/Deviot
def createCompletions():
    """
    Generate the completions file
    """
    try:
        from . import Paths
        from .JSONFile import JSONFile
    except:
        from libs import Paths
        from libs.JSONFile import JSONFile

    keywords = getKeywords()
    keyword_ids = []
    user_path = Paths.getDeviotUserPath()
    completion_path = os.path.join(user_path, 'Deviot.sublime-completions')

    cpp_keywords = ['define', 'error', 'include', 'elif', 'endif']
    cpp_keywords += ['ifdef', 'ifndef', 'undef', 'line', 'pragma']

    for k in keywords:
        for w in k.get_keywords():
            keyword_ids += [w.get_id() for w in k.get_keywords()]

    keyword_ids = set(keyword_ids)
    keyword_ids = [word for word in keyword_ids]

    completions_dict = {'scope': 'source.iot'}
    completions_dict['completions'] = keyword_ids

    file = JSONFile(completion_path)
    file.setData(completions_dict)
示例#17
0
    def endSetup(self):
        try:
            from .PlatformioCLI import generateFiles
        except:
            from libs.PlatformioCLI import generateFiles

        # save env paths
        if(self.os != 'osx'):
            env_path = [self.env_bin_dir]
            self.saveEnvPaths(env_path)

        # get pio version
        if(self.os == 'osx'):
            executable = os.path.join(self.env_bin_dir, 'python')
            cmd = ['"%s"' % (executable), '-m', 'platformio', '--version']
        else:
            executable = os.path.join(self.env_bin_dir, 'pio')
            cmd = ['"%s"' % (executable), '--version']
        out = childProcess(cmd)

        pio_version = match(r"\w+\W \w+ (.+)", out[1]).group(1)
        self.Preferences.set('pio_version', pio_version)

        # copy menu
        sys_os = Tools.getOsName()
        preset_path = Paths.getPresetPath()
        plg_path = Paths.getPluginPath()
        dst = os.path.join(plg_path, 'Settings-Default', 'Main.sublime-menu')

        if(sys_os == 'windows'):
            if(platform.release() == '7'):
                src_path = os.path.join(preset_path, 'Main.sublime-menu.w7')
            else:    
                src_path = os.path.join(preset_path, 'Main.sublime-menu.windows')
            copy(src_path, dst)
        elif(sys_os == 'osx'):
            src_path = os.path.join(preset_path, 'Main.sublime-menu.osx')
            copy(src_path, dst)
        else:
            src_path = os.path.join(preset_path, 'Main.sublime-menu.linux')
            copy(src_path, dst)

        # creating files (menu, completions, syntax)
        sublime.set_timeout(generateFiles, 0)

        self.Preferences.set('protected', True)
        self.Preferences.set('enable_menu', True)
示例#18
0
    def getSublimeMenu(self, user_path=False):
        """
        Get the data of the different files that make up the main menu

        Keyword Arguments:
        user_path {boolean} -- True: get file from Packages/Deviot/Preset
                            --False: get file from Packages/User/Deviot/Preset
                              (Defaul:False)
        """
        menu_path = Paths.getSublimeMenuPath(user_path)
        menu_file = JSONFile(menu_path)
        menu_data = menu_file.getData()
        return menu_data
示例#19
0
文件: Menu.py 项目: goolic/Deviot
    def getSublimeMenu(self, user_path=False):
        """
        Get the data of the different files that make up the main menu

        Keyword Arguments:
        user_path {boolean} -- True: get file from Packages/Deviot/Preset
                            --False: get file from Packages/User/Deviot/Preset
                              (Defaul:False)
        """
        menu_path = Paths.getSublimeMenuPath(user_path)
        menu_file = JSONFile(menu_path)
        menu_data = menu_file.getData()
        return menu_data
示例#20
0
    def getTemplateMenu(self, file_name, user_path=False):
        """
        Get the template menu file to be modified by the different methods

        Arguments
        file_name {string} -name of the file including the extension
        user_path {boolean} -- True: get file from Packages/Deviot/Preset
                            --False: get file from Packages/User/Deviot/Preset
                              (Defaul:False)
        """
        file_path = Paths.getTemplateMenuPath(file_name, user_path)
        preset_file = JSONFile(file_path)
        preset_data = preset_file.getData()
        return preset_data
示例#21
0
文件: Menu.py 项目: goolic/Deviot
    def getTemplateMenu(self, file_name, user_path=False):
        """
        Get the template menu file to be modified by the different methods

        Arguments
        file_name {string} -name of the file including the extension
        user_path {boolean} -- True: get file from Packages/Deviot/Preset
                            --False: get file from Packages/User/Deviot/Preset
                              (Defaul:False)
        """
        file_path = Paths.getTemplateMenuPath(file_name, user_path)
        preset_file = JSONFile(file_path)
        preset_data = preset_file.getData()
        return preset_data
示例#22
0
    def saveTemplateMenu(self, data, file_name, user_path=False):
        """
        Save the menu template in json format

        Arguments:
        data {json} -- st json object with the data of the menu
        file_name {string} -- name of  the file including the extension
        user_path {boolean} -- True: save file in Packages/Deviot/Preset
                            --False: save file in Packages/User/Deviot/Preset
                              (Defaul:False)
        """
        file_path = Paths.getTemplateMenuPath(file_name, user_path)
        preset_file = JSONFile(file_path)
        preset_file.setData(data)
        preset_file.saveData()
示例#23
0
文件: Menu.py 项目: goolic/Deviot
    def saveTemplateMenu(self, data, file_name, user_path=False):
        """
        Save the menu template in json format

        Arguments:
        data {json} -- st json object with the data of the menu
        file_name {string} -- name of  the file including the extension
        user_path {boolean} -- True: save file in Packages/Deviot/Preset
                            --False: save file in Packages/User/Deviot/Preset
                              (Defaul:False)
        """
        file_path = Paths.getTemplateMenuPath(file_name, user_path)
        preset_file = JSONFile(file_path)
        preset_file.setData(data)
        preset_file.saveData()
示例#24
0
    def saveLibraryData(self, data, file_name):
        """
        Stores the data of the libraries in a json file

        Arguments:
            data {json}
                json data with the libraries
            file_name {string}
                name of the json file
        """
        libraries_path = Paths.getLibraryPath()
        library_path = os.path.join(libraries_path, file_name)
        libraries = JSONFile(library_path)
        libraries.setData(data)
        libraries.saveData()
示例#25
0
    def saveLibraryData(self, data, file_name):
        """
        Stores the data of the libraries in a json file

        Arguments:
            data {json}
                json data with the libraries
            file_name {string}
                name of the json file
        """
        libraries_path = Paths.getLibraryPath()
        library_path = os.path.join(libraries_path, file_name)
        libraries = JSONFile(library_path)
        libraries.setData(data)
        libraries.saveData()
示例#26
0
    def overrideSrc(self, ini_path, src_dir):
        """
        Append in the platformio.ini file, the src_dir option
        to override the source folder where the sketch is stored

        Arguments:
            ini_path {string} -- path of the platformio.ini file
            src_dir {string} -- path where source folder the is located
        """
        header = '[platformio]'
        ini_path = Paths.getFullIniPath(self.dir)
        with open(ini_path) as file:
            if header not in file.read():
                with open(ini_path, 'a+') as new_file:
                    new_file.write("\n%s\n" % header)
                    new_file.write("src_dir=%s\n" % src_dir)
示例#27
0
def generateFiles(install=False):
    # Creates new menu
    api_boards = Paths.getTemplateMenuPath('platformio_boards.json',
                                           user_path=True)
    # create main files
    PlatformioCLI().saveAPIBoards(install=install)
    Menu().createMainMenu()

    Tools.createCompletions()
    Tools.createSyntaxFile()
    Menu().createLibraryImportMenu()
    Menu().createLibraryExamplesMenu()

    # Run serial port listener
    Serial = SerialListener(func=Menu().createSerialPortsMenu)
    Serial.start()
示例#28
0
    def getLibrary(self, file_name):
        """
        Get a specific json file and return the data

        Arguments:
            file_name {string}
                Json file name where is stored the library data

        Returns:
            [dict] -- Dictionary with the library data
        """
        plugin_path = Paths.getLibraryPath()
        library_path = os.path.join(plugin_path, file_name)
        libraries = JSONFile(library_path).getData()

        return libraries
示例#29
0
def generateFiles(install=False):
    # Creates new menu
    api_boards = Paths.getTemplateMenuPath('platformio_boards.json',
                                           user_path=True)
    # create main files
    PlatformioCLI().saveAPIBoards(install=install)
    Menu().createMainMenu()

    Tools.createCompletions()
    Tools.createSyntaxFile()
    Menu().createLibraryImportMenu()
    Menu().createLibraryExamplesMenu()

    # Run serial port listener
    Serial = SerialListener(func=Menu().createSerialPortsMenu)
    Serial.start()
示例#30
0
    def getLibrary(self, file_name):
        """
        Get a specific json file and return the data

        Arguments:
            file_name {string}
                Json file name where is stored the library data

        Returns:
            [dict] -- Dictionary with the library data
        """
        plugin_path = Paths.getLibraryPath()
        library_path = os.path.join(plugin_path, file_name)
        libraries = JSONFile(library_path).getData()

        return libraries
示例#31
0
    def overrideSrc(self, ini_path, src_dir):
        """
        Append in the platformio.ini file, the src_dir option
        to override the source folder where the sketch is stored

        Arguments:
            ini_path {string} -- path of the platformio.ini file
            src_dir {string} -- path where source folder the is located
        """
        header = '[platformio]'
        ini_path = Paths.getFullIniPath(self.dir)
        with open(ini_path) as file:
            if header not in file.read():
                with open(ini_path, 'a+') as new_file:
                    new_file.write("\n%s\n" % header)
                    new_file.write("src_dir=%s\n" % src_dir)
示例#32
0
    def saveSublimeMenu(self, data, sub_folder=False, user_path=False):
        """
        Save the data in different files to make up the main menu

        Arguments:
        data {json} -- json st data to create the menu

        Keyword Arguments:
        sub_folder {string/bool} -- name of the sub folder to save the file
                                 -- (default: False)
        user_path {boolean} -- True: Save file in Packages/Deviot/Preset
                            -- False: Save file in Packages/User/Deviot/Preset
                               (Defaul:False)
        """
        menu_file_path = Paths.getSublimeMenuPath(sub_folder, user_path)
        file_menu = JSONFile(menu_file_path)
        file_menu.setData(data)
        file_menu.saveData()
示例#33
0
文件: Menu.py 项目: goolic/Deviot
    def saveSublimeMenu(self, data, sub_folder=False, user_path=False):
        """
        Save the data in different files to make up the main menu

        Arguments:
        data {json} -- json st data to create the menu

        Keyword Arguments:
        sub_folder {string/bool} -- name of the sub folder to save the file
                                 -- (default: False)
        user_path {boolean} -- True: Save file in Packages/Deviot/Preset
                            -- False: Save file in Packages/User/Deviot/Preset
                               (Defaul:False)
        """
        menu_file_path = Paths.getSublimeMenuPath(sub_folder, user_path)
        file_menu = JSONFile(menu_file_path)
        file_menu.setData(data)
        file_menu.saveData()
示例#34
0
文件: Menu.py 项目: goolic/Deviot
    def createMainMenu(self):
        '''
        Creates the main menu with the differents options
        including boards, libraries, and user options.
        '''
        boards = self.createBoardsMenu()

        if(not boards):
            return False

        menu_data = self.getTemplateMenu(file_name='menu_main.json')

        # Main Menu
        for first_menu in menu_data[0]:
            for second_menu in menu_data[0][first_menu]:
                if 'caption' in second_menu:
                    second_menu['caption'] = _(second_menu['caption'])
                if 'children' in second_menu:
                    if(second_menu['id'] == 'select_board'):
                        second_menu['children'] = boards

        # sub menu translation (avoiding the boards menu)
        for third_menu in menu_data[0]['children']:
            try:
                for caption in third_menu['children']:
                    caption['caption'] = _(caption['caption'])
                    try:
                        for item in caption['children']:
                            item['caption'] = _(item['caption'])
                    except:
                        pass

            except:
                pass

        self.saveSublimeMenu(data=menu_data)

        env_path = Paths.getSublimeMenuPath(
            'environment', user_path=True)

        if(os.path.isfile(env_path)):
            self.createEnvironmentMenu()

        self.createLanguageMenu()
示例#35
0
    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)
示例#36
0
    def createMainMenu(self):
        '''
        Creates the main menu with the differents options
        including boards, libraries, and user options.
        '''
        boards = self.createBoardsMenu()

        if (not boards):
            return False

        menu_data = self.getTemplateMenu(file_name='menu_main.json')

        # Main Menu
        for first_menu in menu_data[0]:
            for second_menu in menu_data[0][first_menu]:
                if 'caption' in second_menu:
                    second_menu['caption'] = _(second_menu['caption'])
                if 'children' in second_menu:
                    if (second_menu['id'] == 'select_board'):
                        second_menu['children'] = boards

        # sub menu translation (avoiding the boards menu)
        for third_menu in menu_data[0]['children']:
            try:
                for caption in third_menu['children']:
                    caption['caption'] = _(caption['caption'])
                    try:
                        for item in caption['children']:
                            item['caption'] = _(item['caption'])
                    except:
                        pass

            except:
                pass

        self.saveSublimeMenu(data=menu_data)

        env_path = Paths.getSublimeMenuPath('environment', user_path=True)

        if (os.path.isfile(env_path)):
            self.createEnvironmentMenu()

        self.createLanguageMenu()
示例#37
0
文件: Menu.py 项目: goolic/Deviot
    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)
示例#38
0
文件: Tools.py 项目: margyle/Deviot
def createSketch(sketch_name, path):
    try:
        from . import Paths
        from .Preferences import Preferences
    except:
        from libs import Paths
        from libs.Preferences import Preferences

    # file path
    sketch_path = os.path.join(path, sketch_name)
    if not os.path.exists(sketch_path):
        os.makedirs(sketch_path)

    # use cpp file/template intead of ino
    cpp = Preferences().get('use_cpp', False)
    if cpp:
        ext = '.cpp'
    else:
        ext = '.ino'

    # get template
    template_file_name = 'template' + ext
    preset_path = Paths.getPresetPath()
    template_file_path = os.path.join(preset_path, template_file_name)
    with open(template_file_path) as file:
        src_code = file.read()
    src_file_name = sketch_name + ext
    src_file_path = os.path.join(sketch_path, src_file_name)

    # save new file
    with open(src_file_path, 'w') as src_file:
        src_code = src_code.replace('${src_file_name}', src_file_name)
        src_file.write(src_code)

    # open new file
    views = []
    window = sublime.active_window()
    view = window.open_file(src_file_path)
    views.append(view)
    if views:
        window.focus_view(views[0])
示例#39
0
    def checkInitFile(self):
        """
        Check each platformio.ini file and loads the environments already
        initialized.
        """
        protected = self.Preferences.get('protected', False)
        if(not protected):
            return
        # Empy menu if it's not a IoT file
        if(not self.is_iot):
            if(Tools.getPythonVersion() > 2):
                self.Menu.createEnvironmentMenu(empty=True)
            return

        ini_path = Paths.getFullIniPath(self.dir)

        # show non native data
        if(not self.is_native):
            self.Preferences.set('native', False)
            self.Preferences.set('ini_path', self.dir)
            self.Menu.createEnvironmentMenu()
            return
        else:
            self.Preferences.set('native', True)
            self.Preferences.set('ini_path', self.dir)

        # get data from platformio.ini file
        ini_list = []
        with open(ini_path, 'r') as file:
            pattern = compile(r'\[(\w+)\W(\w+)\]')
            for line in file:
                if pattern.findall(line):
                    if('#' not in line):
                        line = match(r"\[\w+:(\w+)\]", line).group(1)
                        ini_list.append(line)

        # save preferences, update menu data
        type = 'board_id' if not self.is_native else 'found_ini'
        self.Preferences.set(type, ini_list)
        self.Menu.createEnvironmentMenu()
示例#40
0
文件: Tools.py 项目: BadgerAAV/Deviot
def createSketch(sketch_name, path):
    try:
        from . import Paths
        from .Preferences import Preferences
    except:
        from libs import Paths
        from libs.Preferences import Preferences

    # file path
    sketch_path = os.path.join(path, sketch_name)
    if not os.path.exists(sketch_path):
        os.makedirs(sketch_path)

    # use cpp file/template intead of ino
    cpp = Preferences().get('use_cpp', False)
    if cpp:
        ext = '.cpp'
    else:
        ext = '.ino'

    # get template
    template_file_name = 'template' + ext
    preset_path = Paths.getPresetPath()
    template_file_path = os.path.join(preset_path, template_file_name)
    with open(template_file_path) as file:
        src_code = file.read()
    src_file_name = sketch_name + ext
    src_file_path = os.path.join(sketch_path, src_file_name)

    # save new file
    with open(src_file_path, 'w') as src_file:
        src_code = src_code.replace('${src_file_name}', src_file_name)
        src_file.write(src_code)

    # open new file
    window = sublime.active_window()
    view = window.open_file(src_file_path)
    views.append(view)
    if views:
        window.focus_view(views[0])
示例#41
0
    def on_close(self, view):
        """
        When a sketch is closed, temp files are deleted

        Arguments: view {ST object} -- Sublime Text Object
        """
        # Serial Monitor
        monitor_module = Serial
        if Messages.isMonitorView(view):
            name = view.name()
            serial_port = name.split('-')[1].strip()
            if serial_port in monitor_module.serials_in_use:
                cur_serial_monitor = monitor_module.serial_monitor_dict.get(
                    serial_port, None)
                if cur_serial_monitor:
                    cur_serial_monitor.stop()
                monitor_module.serials_in_use.remove(serial_port)

        # Remove cache
        keep_cache = Preferences().get('keep_cache', True)
        if (keep_cache):
            return

        file_path = Tools.getPathFromView(view)
        if (not file_path):
            return
        file_name = Tools.getFileNameFromPath(file_path, ext=False)
        tmp_path = Paths.getTempPath()
        tmp_all = os.path.join(tmp_path, '*')
        tmp_all = glob.glob(tmp_all)

        for content in tmp_all:
            if file_name in content:
                tmp_path = os.path.join(tmp_path, content)
                rmtree(tmp_path, ignore_errors=False)
                Preferences().set('builded_sketch', False)

        # Empty enviroment menu
        Menu().createEnvironmentMenu(empty=True)
示例#42
0
文件: Tools.py 项目: BadgerAAV/Deviot
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
示例#43
0
    def on_close(self, view):
        """
        When a sketch is closed, temp files are deleted

        Arguments: view {ST object} -- Sublime Text Object
        """
        # Serial Monitor
        monitor_module = Serial
        if Messages.isMonitorView(view):
            name = view.name()
            serial_port = name.split('-')[1].strip()
            if serial_port in monitor_module.serials_in_use:
                cur_serial_monitor = monitor_module.serial_monitor_dict.get(
                    serial_port, None)
                if cur_serial_monitor:
                    cur_serial_monitor.stop()
                monitor_module.serials_in_use.remove(serial_port)

        # Remove cache
        keep_cache = Preferences().get('keep_cache', True)
        if(keep_cache):
            return

        file_path = Tools.getPathFromView(view)
        if(not file_path):
            return
        file_name = Tools.getFileNameFromPath(file_path, ext=False)
        tmp_path = Paths.getTempPath()
        tmp_all = os.path.join(tmp_path, '*')
        tmp_all = glob.glob(tmp_all)

        for content in tmp_all:
            if file_name in content:
                tmp_path = os.path.join(tmp_path, content)
                rmtree(tmp_path, ignore_errors=False)
                Preferences().set('builded_sketch', False)

        # Empty enviroment menu
        Menu().createEnvironmentMenu(empty=True)
示例#44
0
文件: Tools.py 项目: margyle/Deviot
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
示例#45
0
    def checkInitFile(self):
        """
        Check each platformio.ini file and loads the environments already
        initialized.
        """
        protected = self.Preferences.get('protected', False)
        if (not protected):
            return
        # Empy menu if it's not a IoT file
        if (not self.is_iot):
            return

        ini_path = Paths.getFullIniPath(self.dir)

        # show non native data
        if (not self.is_native):
            self.Preferences.set('native', False)
            self.Preferences.set('ini_path', self.dir)
            self.Menu.createEnvironmentMenu()
            return
        else:
            self.Preferences.set('native', True)
            self.Preferences.set('ini_path', self.dir)

        # get data from platformio.ini file
        ini_list = []
        with open(ini_path, 'r') as file:
            pattern = compile(r'\[(\w+)\W(\w+)\]')
            for line in file:
                if pattern.findall(line):
                    if ('#' not in line):
                        line = match(r"\[\w+:(\w+)\]", line).group(1)
                        ini_list.append(line)

        # save preferences, update menu data
        type = 'board_id' if not self.is_native else 'found_ini'
        self.Preferences.set(type, ini_list)
        self.Menu.createEnvironmentMenu()
示例#46
0
    def __init__(self, view=False, console=False, install=False, command=True):
        '''
        Initialize the command and preferences classes, to check
        if the current work file is an IoT type it received the view
        parameter (ST parameter). This parameter is necessary only in
        the options like build or upload.

        Keyword Arguments:
        view {st object} -- stores many info related with ST (default: False)
        '''
        self.Preferences = Preferences()
        self.Menu = Menu()

        # user console
        if (console):
            current_time = time.strftime('%H:%M:%S')
            self.message_queue = MessageQueue(console)
            self.message_queue.startPrint()

        # For installing purposes
        if (install):
            self.Commands = CommandsPy(console=console)
            return

        self.view = view
        self.execute = True
        self.is_native = False
        self.is_iot = False

        if (view):
            # avoid to do anything with a monitor view
            view_name = view.name()
            sketch_size = view.size()
            file_path = Tools.getPathFromView(view)

            if (not file_path and 'monitor' in view_name.lower()):
                try:
                    current_time = time.strftime('%H:%M:%S')
                    self.message_queue.put('invalid_file_{0}', current_time)
                except:
                    pass
                self.execute = False
                return

            # unsaved file
            if (command and not file_path and sketch_size > 0):
                saved_file = self.saveCodeInFile(view)
                view = saved_file[1]
                file_path = Tools.getPathFromView(view)

            if (command and not sketch_size):
                self.message_queue.put('not_empty_sketch_{0}', current_time)

            # current file / view
            current_path = Paths.getCurrentFilePath(view)
            if (not current_path):
                return
            self.is_iot = Tools.isIOTFile(view)
            current_dir = Paths.getCWD(current_path)
            parent_dir = Paths.getParentCWD(current_path)
            file_name = Tools.getFileNameFromPath(file_path)
            temp_name = Tools.getFileNameFromPath(current_path, ext=False)

            if (not self.is_iot):
                self.execute = False

            # check IoT type file
            if (console and not self.is_iot and not self.execute):
                current_time = time.strftime('%H:%M:%S')
                msg = 'not_iot_{0}{1}'
                if (not file_name):
                    msg = 'not_empty_sketch_{0}'
                self.message_queue.put(msg, current_time, file_name)
                self.execute = False
                return

            if (not command and not self.is_iot):
                return

            # Check native project
            for file in os.listdir(parent_dir):
                if (file.endswith('platformio.ini')):
                    self.dir = parent_dir
                    self.src = False
                    self.is_native = True
                    break

            # set native paths
            if (not self.is_native):
                build_dir = Paths.getBuildPath(temp_name)
                if (not build_dir):
                    build_dir = Paths.getTempPath(temp_name)
                self.src = current_dir
                self.dir = build_dir

            # unsaved changes
            if (command and view.is_dirty()):
                view.run_command('save')

            if (console):
                self.message_queue.put('[ Deviot {0} ] {1}\\n', version,
                                       file_name)
                time.sleep(0.02)

            # Initilized commands
            self.Commands = CommandsPy(console=console, cwd=self.dir)
示例#47
0
 def run(self, edit):
     temp = Paths.getTempPath()
     url = Paths.getOpenFolderPath(temp)
     sublime.run_command('open_url', {'url': url})
示例#48
0
 def run(self, edit):
     library = Paths.getPioLibrary()
     url = Paths.getOpenFolderPath(library)
     sublime.run_command('open_url', {'url': url})
示例#49
0
 def on_done(self, sketch_name):
     Paths.selectDir(self.window, key=sketch_name, func=Tools.createSketch)
示例#50
0
 def run(self):
     Paths.selectDir(self.window, key='build_dir', func=Preferences().set)
示例#51
0
 def run(self, edit):
     temp = Paths.getTempPath()
     url = Paths.getOpenFolderPath(temp)
     sublime.run_command('open_url', {'url': url})
示例#52
0
 def run(self, edit):
     library = Paths.getPioLibrary()
     url = Paths.getOpenFolderPath(library)
     sublime.run_command('open_url', {'url': url})
示例#53
0
 def run(self):
     Paths.selectDir(self.window,
                     key='default_path',
                     func=Preferences().set)
示例#54
0
    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 (not os.path.exists(library_json)):
                        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)
示例#55
0
 def run(self):
     Paths.selectDir(self.window, key='build_dir', func=Preferences().set)
示例#56
0
    def __init__(self, view=False, console=False, install=False, command=True):
        '''
        Initialize the command and preferences classes, to check
        if the current work file is an IoT type it received the view
        parameter (ST parameter). This parameter is necessary only in
        the options like build or upload.

        Keyword Arguments:
        view {st object} -- stores many info related with ST (default: False)
        '''
        self.Preferences = Preferences()
        self.Menu = Menu()

        # user console
        if(console):
            current_time = time.strftime('%H:%M:%S')
            self.message_queue = MessageQueue(console)
            self.message_queue.startPrint()

        # For installing purposes
        if(install):
            self.Commands = CommandsPy(console=console)
            return

        self.view = view
        self.execute = True
        self.is_native = False
        self.is_iot = False

        if(view):
            # avoid to do anything with a monitor view
            view_name = view.name()
            sketch_size = view.size()
            file_path = Tools.getPathFromView(view)

            if(not file_path and 'monitor' in view_name.lower()):
                try:
                    current_time = time.strftime('%H:%M:%S')
                    self.message_queue.put('invalid_file_{0}', current_time)
                except:
                    pass
                self.execute = False
                return

            # unsaved file
            if(command and not file_path and sketch_size > 0):
                saved_file = self.saveCodeInFile(view)
                view = saved_file[1]
                file_path = Tools.getPathFromView(view)

            if(command and not sketch_size):
                self.message_queue.put('not_empty_sketch_{0}', current_time)

            # current file / view
            current_path = Paths.getCurrentFilePath(view)
            if(not current_path):
                return
            self.is_iot = Tools.isIOTFile(view)
            current_dir = Paths.getCWD(current_path)
            parent_dir = Paths.getParentCWD(current_path)
            file_name = Tools.getFileNameFromPath(file_path)
            temp_name = Tools.getFileNameFromPath(current_path, ext=False)

            if(not self.is_iot):
                self.execute = False

            # check IoT type file
            if(console and not self.is_iot and not self.execute):
                current_time = time.strftime('%H:%M:%S')
                msg = 'not_iot_{0}{1}'
                if(not file_name):
                    msg = 'not_empty_sketch_{0}'
                self.message_queue.put(msg, current_time, file_name)
                self.execute = False
                return

            if(not command and not self.is_iot):
                return

            # Check native project
            for file in os.listdir(parent_dir):
                if(file.endswith('platformio.ini')):
                    self.dir = parent_dir
                    self.src = False
                    self.is_native = True
                    break

            # set native paths
            if(not self.is_native):
                build_dir = self.Preferences.get('build_dir', False)
                if(not build_dir):
                    build_dir = Paths.getTempPath(temp_name)
                self.src = current_dir
                self.dir = build_dir

            # unsaved changes
            if (command and view.is_dirty()):
                view.run_command('save')

            if(console):
                self.message_queue.put(
                    '[ Deviot {0} ] {1}\\n', version, file_name)
                time.sleep(0.02)

            # Initilized commands
            self.Commands = CommandsPy(console=console, cwd=self.dir)
示例#57
0
 def run(self):
     Paths.selectDir(self.window, key='default_path',
                     func=Preferences().set)
示例#58
0
文件: Menu.py 项目: goolic/Deviot
    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)