当前位置: 首页>>代码示例>>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;未经允许,请勿转载。