Also handle instrument names like 1a (and sort them correctly) in the webshop definit...
authorReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 20 Nov 2012 21:59:22 +0000 (20 22:59 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 20 Nov 2012 22:03:32 +0000 (20 23:03 +0100)
generate_oly_score.py

index b7361d9..33e0f93 100755 (executable)
@@ -553,9 +553,16 @@ def generate_webshop_files (settings, lily_files, tex_files):
       if i in noscore_instruments:
         continue;
       score_info = score_types.get (i, {});
-      score_type = score_info.get ("Name", "");
+      score_type = score_info.get ("Name", i);
       score_id = score_info.get ("Number", "XXX");
-      sid = int(score_id);
+      try:
+        # Replace '1a' to 1.01 (i.e. appended letters will indicate decimals, so they are sorted after 1)
+        def chartoindex(matchobj):
+          return "%s.%02d" % (matchobj.group(1), ord(matchobj.group(2).lower())-96);
+        sid = re.sub(r'^([0-9]+)([a-zA-Z])$', chartoindex, score_id);
+        sid = float(sid);
+      except ValueError as e:
+        sid = score_id;
       scores.append({"id": sid, "sku": score_settings.get ("scorenumber")+"-"+score_id, "type": score_type });
   
   webshop_settings["webshop_editions"] = sorted (scores, key=lambda k: k.get("id", 0));