From c3a62e0150c85c1e27ae32a79b107b57322fa322 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sun, 14 Jul 2013 09:48:29 +0200 Subject: [PATCH] portage.settings.repositories.config_string(): Improve format of returned string. --- pym/portage/repository/config.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index 676e7e300..65c43d664 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -832,19 +832,24 @@ class RepoConfigLoader(object): return repo_name in self.prepos def config_string(self): + str_or_int_keys = ("format", "location", "main_repo", "priority", "sync") + tuple_keys = ("aliases", "eclass_overrides") + repo_config_tuple_keys = ("masters",) + keys = str_or_int_keys + tuple_keys + repo_config_tuple_keys config_string = "" - for repo_name, repo in self.prepos.items(): - config_string += "[%s]\n" % repo_name - for key in ("format", "location", "main_repo", "priority", "sync"): - if getattr(repo, key) is not None: - config_string += "%s = %s\n" % (key.replace("_", "-"), getattr(repo, key)) - for key in ("aliases", "eclass_overrides"): - if getattr(repo, key) is not None: - config_string += "%s = %s\n" % (key.replace("_", "-"), " ".join(getattr(repo, key))) - for key in ("masters",): + for repo_name, repo in sorted(self.prepos.items()): + config_string += "\n[%s]\n" % repo_name + for key in sorted(keys): + if key == "main_repo" and repo_name != "DEFAULT": + continue if getattr(repo, key) is not None: - config_string += "%s = %s\n" % (key.replace("_", "-"), " ".join(x.name for x in getattr(repo, key))) - return config_string + if key in str_or_int_keys: + config_string += "%s = %s\n" % (key.replace("_", "-"), getattr(repo, key)) + elif key in tuple_keys: + config_string += "%s = %s\n" % (key.replace("_", "-"), " ".join(getattr(repo, key))) + elif key in repo_config_tuple_keys: + config_string += "%s = %s\n" % (key.replace("_", "-"), " ".join(x.name for x in getattr(repo, key))) + return config_string.lstrip("\n") def load_repository_config(settings, extra_files=None): repoconfigpaths = [] -- 2.26.2