@@ -105,33 +105,20 @@ def process_chart(params, chart_dict, omit_list, other, no_program):
105105
106106 if priority_codes is not None :
107107 if short in priority_codes :
108- # Since Python 3.7, python dictionaries preserve insertion
109- # order, so to prepend an item to the top of the dictionary,
110- # we create a new dictionary inserting the target code first,
111- # then add the previous output, and finally save the new
112- # dictionary as our output dictionary.
113- new_chart = {short : name }
114- new_chart .update (out_chart )
115- out_chart = new_chart
116- found_codes .append (short )
108+ out_chart = util .dict_prepend (out_chart , short , name )
117109 else :
118110 out_chart [short ] = name
119- found_codes .append (short )
120111 else :
121112 out_chart [short ] = name
122- found_codes .append (short )
113+ found_codes .append (short )
123114
124115 # inject "other" code
125116 if util .param_other_bool (params ):
126- new_chart = {other : "Other" }
127- new_chart .update (out_chart )
128- out_chart = new_chart
117+ out_chart = util .dict_prepend (out_chart , other , "Other" )
129118
130119 # inject "no program" code
131120 if util .param_no_program_bool (params ):
132- new_chart = {no_program : "No Program" }
133- new_chart .update (out_chart )
134- out_chart = new_chart
121+ out_chart = util .dict_prepend (out_chart , no_program , "No Program" )
135122
136123 return out_chart
137124
0 commit comments