1 |
commit: d3c490a9411769f6dfdf241dbcee7ae6b717eab4 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jul 2 16:53:33 2015 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jul 2 16:53:33 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=d3c490a9 |
7 |
|
8 |
make-worldconf: sort the sections of world.conf. |
9 |
|
10 |
make-worldconf | 12 ++++++++++-- |
11 |
1 file changed, 10 insertions(+), 2 deletions(-) |
12 |
|
13 |
diff --git a/make-worldconf b/make-worldconf |
14 |
index 5ab0b46..09de316 100755 |
15 |
--- a/make-worldconf |
16 |
+++ b/make-worldconf |
17 |
@@ -121,7 +121,7 @@ def main(): |
18 |
config = configparser.RawConfigParser(delimiters=':', allow_no_value=True, comment_prefixes=None) |
19 |
|
20 |
for p in mydepgraph.altlist(): |
21 |
- # Prepare a section for this atom |
22 |
+ # Prepare an empty section for this atom |
23 |
try: |
24 |
config[p.slot_atom] = {} |
25 |
except AttributeError: |
26 |
@@ -136,11 +136,19 @@ def main(): |
27 |
# Populate package.env and env/* |
28 |
envvars(config, p) |
29 |
|
30 |
+ # Remove any empty sections |
31 |
if config[p.slot_atom] == {}: |
32 |
config.remove_section(p.slot_atom) |
33 |
|
34 |
+ # Recontruct a RawConfigParser from the above which has sorted sections. |
35 |
+ all_slot_atoms = config.sections() |
36 |
+ all_slot_atoms.sort() |
37 |
+ sorted_config = configparser.RawConfigParser(delimiters=':', allow_no_value=True, comment_prefixes=None) |
38 |
+ for s in all_slot_atoms: |
39 |
+ sorted_config[s] = config[s] |
40 |
+ |
41 |
with open('world.conf', 'w') as configfile: |
42 |
- config.write(configfile) |
43 |
+ sorted_config.write(configfile) |
44 |
|
45 |
if __name__ == "__main__": |
46 |
main() |