The manifest-repos command currently does not check for the existance of the 'manifest-repos' section in the edkrepo_user.cfg file. This change adds the check.
Signed-off-by: Nate DeSimone <nathaniel.l.desim...@intel.com> Cc: Ashley E Desimone <ashley.e.desim...@intel.com> Cc: Nate DeSimone <nathaniel.l.desim...@intel.com> Cc: Puja Pandya <puja.pan...@intel.com> Cc: Bret Barkelew <bret.barke...@microsoft.com> Cc: Prince Agyeman <prince.agye...@intel.com> Cc: Erik Bjorge <erik.c.bjo...@intel.com> --- edkrepo/commands/manifest_repos_command.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/edkrepo/commands/manifest_repos_command.py b/edkrepo/commands/manifest_repos_command.py index b817662..3dbe604 100644 --- a/edkrepo/commands/manifest_repos_command.py +++ b/edkrepo/commands/manifest_repos_command.py @@ -95,13 +95,24 @@ class ManifestRepos(EdkrepoCommand): user_cfg_file = configparser.ConfigParser(allow_no_value=True) user_cfg_file.read(user_cfg_file_path) if args.action == 'add': + if not user_cfg_file.has_section('manifest-repos'): + user_cfg_file.add_section('manifest-repos') user_cfg_file.set('manifest-repos', args.name, None) user_cfg_file.add_section(args.name) user_cfg_file.set(args.name, 'URL', args.url) user_cfg_file.set(args.name, 'Branch', args.branch) user_cfg_file.set(args.name, 'LocalPath', args.path) if args.action == 'remove': - user_cfg_file.remove_option('manifest-repos', args.name) - user_cfg_file.remove_section(args.name) + if user_cfg_file.has_section('manifest-repos'): + if user_cfg_file.has_option('manifest-repos', args.name): + user_cfg_file.remove_option('manifest-repos', args.name) + else: + raise EdkrepoInvalidParametersException(humble.REMOVE_NOT_EXIST) + else: + raise EdkrepoInvalidParametersException(humble.REMOVE_NOT_EXIST) + if user_cfg_file.has_section(args.name): + user_cfg_file.remove_section(args.name) + else: + raise EdkrepoInvalidParametersException(humble.REMOVE_NOT_EXIST) with open(user_cfg_file_path, 'w') as cfg_stream: user_cfg_file.write(cfg_stream) -- 2.26.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60915): https://edk2.groups.io/g/devel/message/60915 Mute This Topic: https://groups.io/mt/74762422/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-