Templates: Sort scores by score edition number (need id field for this)
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 3 Nov 2012 19:52:36 +0000 (3 20:52 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 3 Nov 2012 19:53:09 +0000 (3 20:53 +0100)
generate_oly_score.py

index d24b1cd..983a680 100755 (executable)
@@ -555,9 +555,12 @@ def generate_webshop_files (settings, lily_files, tex_files):
       score_info = score_types.get (i, {});
       score_type = score_info.get ("Name", "");
       score_id = score_info.get ("Number", "XXX");
-      scores.append({"sku": score_settings.get ("scorenumber")+"-"+score_id, "type": score_type });
+      sid = int(score_id);
+      scores.append({"id": sid, "sku": score_settings.get ("scorenumber")+"-"+score_id, "type": score_type });
   
-  webshop_settings["webshop_editions"] = scores;
+  webshop_settings["webshop_editions"] = sorted (scores, key=lambda k: k.get("id", 0));
+  
+  webshop_settings.update (webshop_settings.get("defaults", {}));
   file = write_file (settings.out_dir, "webshop_descriptions.def", template.render (webshop_settings));