當前位置: 首頁>>代碼示例>>Python>>正文


Python Paths.getFullIniPath方法代碼示例

本文整理匯總了Python中libs.Paths.getFullIniPath方法的典型用法代碼示例。如果您正苦於以下問題:Python Paths.getFullIniPath方法的具體用法?Python Paths.getFullIniPath怎麽用?Python Paths.getFullIniPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在libs.Paths的用法示例。


在下文中一共展示了Paths.getFullIniPath方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: initSketchProject

# 需要導入模塊: from libs import Paths [as 別名]
# 或者: from libs.Paths import getFullIniPath [as 別名]
    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)
開發者ID:BadgerAAV,項目名稱:Deviot,代碼行數:33,代碼來源:PlatformioCLI.py

示例2: removeEnvFromFile

# 需要導入模塊: from libs import Paths [as 別名]
# 或者: from libs.Paths import getFullIniPath [as 別名]
    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)
開發者ID:BadgerAAV,項目名稱:Deviot,代碼行數:36,代碼來源:PlatformioCLI.py

示例3: overrideSrc

# 需要導入模塊: from libs import Paths [as 別名]
# 或者: from libs.Paths import getFullIniPath [as 別名]
    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)
開發者ID:BadgerAAV,項目名稱:Deviot,代碼行數:18,代碼來源:PlatformioCLI.py

示例4: checkInitFile

# 需要導入模塊: from libs import Paths [as 別名]
# 或者: from libs.Paths import getFullIniPath [as 別名]
    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()
開發者ID:BadgerAAV,項目名稱:Deviot,代碼行數:42,代碼來源:PlatformioCLI.py


注:本文中的libs.Paths.getFullIniPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。