Try sorting dictionnary keys to keep order

This commit is contained in:
Loic Guegan 2019-10-09 11:14:53 -04:00
parent 1f92a79588
commit a9774e993f
3 changed files with 12 additions and 6 deletions

View file

@ -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()

View file

@ -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

View file

@ -289,12 +289,12 @@ bar {
status_command i3status -c ~/.config/i3/i3status.conf
separator_symbol "|"
colors {
separator #AAAAAA
background #1f2326
statusline #FFFFFF
focused_workspace #9FCA56 #9FCA56 #151718
active_workspace #DCCD69 #DCCD69 #151718
background #1f2326
focused_workspace #9FCA56 #9FCA56 #151718
inactive_workspace #1f2326 #1f2326 #AAAAAA
separator #AAAAAA
statusline #FFFFFF
urgent_workspace #CE4045 #CE4045 #FFFFFF
}
}