Fixed extra library feature broken after change ConfigObj by ConfigParser
@@ -234,27 +234,27 @@ class PreferencesBridge(PioBridge):
The path of the folder must be set from the option
`add extra folder` in the library option menu
"""
+ lib_flag = 'lib_extra_dirs'
ini_path = self.get_ini_path()
extra = get_setting('extra_library', None)
- Config = ConfigParser()
- ini_file = Config.read(ini_path)
- environment = 'env:{0}'.format(self.board_id)
+ config = ConfigParser()
+ ini_file = config.read(ini_path)
- if(environment not in ini_file):
- return
+ environment = 'env:' + self.board_id
- env = ini_file[environment]
+ if(not config.has_section(environment)):
+ return
- if(not extra):
- if('lib_extra_dirs' in env):
- env.pop('lib_extra_dirs')
+ # remove previous configuration
+ if(config.has_option(environment, lib_flag)):
+ config.remove_option(environment, lib_flag)
if(extra):
- extra_option = {'lib_extra_dirs': extra}
- env.merge(extra_option)
+ config.set(environment, lib_flag, extra)
- ini_file.write()
+ with open(ini_path, 'w') as configfile:
+ config.write(configfile)
def overwrite_baudrate(self):
"""Add new speed
