commit: d3c490a9411769f6dfdf241dbcee7ae6b717eab4
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 2 16:53:33 2015 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Jul 2 16:53:33 2015 +0000
URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=d3c490a9
make-worldconf: sort the sections of world.conf.
make-worldconf | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/make-worldconf b/make-worldconf
index 5ab0b46..09de316 100755
--- a/make-worldconf
+++ b/make-worldconf
@@ -121,7 +121,7 @@ def main():
config = configparser.RawConfigParser(delimiters=':', allow_no_value=True,
comment_prefixes=None)
for p in mydepgraph.altlist():
- # Prepare a section for this atom
+ # Prepare an empty section for this atom
try:
config[p.slot_atom] = {}
except AttributeError:
@@ -136,11 +136,19 @@ def main():
# Populate package.env and env/*
envvars(config, p)
+ # Remove any empty sections
if config[p.slot_atom] == {}:
config.remove_section(p.slot_atom)
+ # Recontruct a RawConfigParser from the above which has sorted sections.
+ all_slot_atoms = config.sections()
+ all_slot_atoms.sort()
+ sorted_config = configparser.RawConfigParser(delimiters=':',
allow_no_value=True, comment_prefixes=None)
+ for s in all_slot_atoms:
+ sorted_config[s] = config[s]
+
with open('world.conf', 'w') as configfile:
- config.write(configfile)
+ sorted_config.write(configfile)
if __name__ == "__main__":
main()