diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2019-10-09 11:14:53 -0400 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2019-10-09 11:16:38 -0400 |
| commit | a9774e993f0eeda6e8bb64b50be449a3e1ebc81c (patch) | |
| tree | 95126ebbe52c8d686eddab2e150578122271d78c | |
| parent | 1f92a795880e9db158713e520c8fcbcaff301c9c (diff) | |
Try sorting dictionnary keys to keep order
| -rwxr-xr-x | src/config.py | 6 | ||||
| -rwxr-xr-x | tests/run.sh | 4 | ||||
| -rw-r--r-- | tests/test-apply-with-vars.out | 6 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/config.py b/src/config.py index bd2366f..cc43712 100755 --- a/src/config.py +++ b/src/config.py @@ -26,6 +26,8 @@ def before_token(token, line): if found: return(found.group(0)[:-len(token)]) return("") +def sorted_items(d): + return(sorted(d.items())) def no_comment(line): """ Remove comment from a line. @@ -113,7 +115,7 @@ def write_theme(tmp_config,theme): if len(beforeBrace)>0: tmp.write(beforeBrace+"\n") tmp.write(" colors {\n") - for key,value in bar_theme.items(): + for key,value in sorted_items(bar_theme): if not(isinstance(value,dict)): tmp.write(" "+key+" "+value+"\n") else: @@ -129,7 +131,7 @@ def write_theme(tmp_config,theme): ##### Apply client theme ##### client_theme=theme["window_colors"] f=open(tmp_config,mode="a") - for key,value in client_theme.items(): + for key,value in sorted_items(client_theme): f.write("client."+key+" "+value["border"]+" "+value["background"]+" "+value["text"]+" "+value["indicator"]+" "+value["child_border"]+"\n") f.close() diff --git a/tests/run.sh b/tests/run.sh index a0eced4..3691700 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -39,6 +39,10 @@ do then echo "========== Diff ==========" echo -e "${diff_out}" + echo "========== Original ==========" + cat "${expectations}" + echo "========== Test Output ==========" + cat "${out}" clean exit 1 fi diff --git a/tests/test-apply-with-vars.out b/tests/test-apply-with-vars.out index b741ee5..5ed41f4 100644 --- a/tests/test-apply-with-vars.out +++ b/tests/test-apply-with-vars.out @@ -289,12 +289,12 @@ bar { status_command i3status -c ~/.config/i3/i3status.conf separator_symbol "|" colors { - separator #AAAAAA + active_workspace #DCCD69 #DCCD69 #151718 background #1f2326 - statusline #FFFFFF focused_workspace #9FCA56 #9FCA56 #151718 - active_workspace #DCCD69 #DCCD69 #151718 inactive_workspace #1f2326 #1f2326 #AAAAAA + separator #AAAAAA + statusline #FFFFFF urgent_workspace #CE4045 #CE4045 #FFFFFF } } |
