Create definitions file for my webshop script
authorReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 2 Nov 2012 20:44:27 +0000 (2 21:44 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 2 Nov 2012 20:44:27 +0000 (2 21:44 +0100)
Templates/EK_Full/webshop_descriptions.def [new file with mode: 0644]
generate_oly_score.py
oly_defs.py [new file with mode: 0644]

diff --git a/Templates/EK_Full/webshop_descriptions.def b/Templates/EK_Full/webshop_descriptions.def
new file mode 100644 (file)
index 0000000..7f70121
--- /dev/null
@@ -0,0 +1,17 @@
+{
+  "title": u"<<shortcomposer|default(composer)>>: << title >>, << subtitle >>",
+
+  "Short_Description_en": u"",
+  "Short_Description_de": u"",
+  
+  "Description_de": u'''<p></p>''',
+  "Description_en": u'''<p></p>''',
+  
+  "Category": u"",
+  
+  "Child_Products": {
+<$- for e in webshop_editions $>
+    "<< e.sku >>": {"ismn": "<<e.ismn>>", "comment": "<<e.comment>>", "price": <<e.price|default(0.00)>>}, # << e.type >>
+<$- endfor $>
+  },
+}
index 8edbf2a..3b1110b 100755 (executable)
@@ -41,6 +41,29 @@ def help (text):
 
 
 
+
+def import_file (filename):
+  res={}
+  try:
+    in_f = codecs.open (filename, "r", "utf-8")
+    s = in_f.read()
+    in_f.close()
+    res = eval(s);
+  except IOError:
+    print ("Unable to load file '%s'. Exiting..." % filename)
+    exit (-1);
+  except SyntaxError as ex:
+    print ex;
+    print ("Unable to interpret settings file '%s', it's syntax is invalid. Exiting..." % filename);
+    exit (-1);
+  return res
+
+
+# Load the score type/number definitions from the oly directory
+score_types = import_file (os.path.join(sys.path[0], "oly_defs.py"));
+
+
+
 ######################################################################
 #   Settings
 ######################################################################
@@ -144,18 +167,7 @@ class Settings:
       return "oly_structure.def";
 
   def load (self, filename):
-    try:
-      in_f = codecs.open (filename, "r", "utf-8")
-      s = in_f.read()
-      in_f.close()
-      self.raw_data = eval(s);
-    except IOError:
-      print ("Unable to load settings file '%s'. Exiting..." % file_name)
-      exit (-1);
-    except SyntaxError as ex:
-      print ex;
-      print ("Unable to interpret settings file '%s', it's syntax is invalid. Exiting..." % filename);
-      exit (-1);
+    self.raw_data = import_file (filename)
     if not self.out_dir:
       self.out_dir = self.raw_data.get ("output_dir", self.out_dir) + "/";
 
@@ -514,18 +526,34 @@ def generate_make_files (settings, lily_files, tex_files):
 
 
 
-#  movements = settings.get ("parts", {});
-#
-#  replacements["instruments"] = string.join (settings.get ("instruments", []));
-#  replacements["scores"] = string.join (settings.get ("scores", []))## + " Instruments";
-#  replacements["srcfiles"] = string.join (src_files);
-#
-#  write_file (output_dir + "Makefile", templates["Makefile"] % replacements);
-#
-#  del replacements["instruments"]
-#  del replacements["scores"]
-#  del replacements["srcfiles"]
-#  return;
+
+######################################################################
+#   Creating webshop_descriptions.def
+######################################################################
+
+def generate_webshop_files (settings, lily_files, tex_files):
+  webshop_settings = settings.raw_data.copy ();
+  template = settings.get_template ("webshop_descriptions.def");
+  #basename = tex_settings.get ("basename", "");
+  #print pp.pprint(settings.raw_data);
+  #print pp.pprint(settings.score_names ())
+
+  scores=[];
+  noscore_instruments = webshop_settings.get ("noscore_instruments", [])
+
+  for s in settings.score_names ():
+    score_settings = settings.get_score_settings (s);
+    for i in score_settings.get ("scores", []) + ["Instruments"] + score_settings.get ("instruments", []):
+      if i in noscore_instruments:
+        continue;
+      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 });
+  
+  webshop_settings["webshop_editions"] = scores;
+  file = write_file (settings.out_dir, "webshop_descriptions.def", template.render (webshop_settings));
+
 
 
 ######################################################################
@@ -557,6 +585,8 @@ def main ():
     tex_files = generate_tex_files (settings, lily_files);
   print ("Creating OrchestralLily package link")
   generate_oly_link (settings);
+  print ("Creating webshop_descriptions.def")
+  generate_webshop_files (settings, lily_files, tex_files);
   print ("Creating Makefile")
   generate_make_files (settings, lily_files, tex_files);
 
diff --git a/oly_defs.py b/oly_defs.py
new file mode 100644 (file)
index 0000000..d9b0da1
--- /dev/null
@@ -0,0 +1,70 @@
+{
+  "Original":  { "Name": "Originalpartitur",                           "Number": "0" },
+  "Full":      { "Name": "Partitur / Full score",                      "Number": "1" },
+  "Long":      { "Name": "Partitur / Full score",                      "Number": "1a" },
+  "Organ":     { "Name": "Orgelauszug / Organ score",                  "Number": "2" },
+  "Vocal":     { "Name": "Klavierauszug / Vocal score",                "Number": "2" },
+  "Particell": { "Name": "Vokalparticell / Vocal particell",           "Number": "3" },
+  "Choral":    { "Name": "Chorstimmen / Choral score",                 "Number": "10" },
+  "SoloChoral":        { "Name": "Chorstimmen mit Soli / Choral score with solo parts", "Number": "15a" },
+  "Solo":      { "Name": "Solostimmen / Solo parts",                   "Number": "15" },
+  "Instruments":{ "Name": "Orchesterstimmen",                          "Number": "25" },
+  "Harmoniestimmen":{"Name": "Harmoniestimmen",                        },
+
+  "Fl":                { "Name": "Flauti",             "Short": "Fl.",         "Number": "40", "Type": "" },
+  "FlI":       { "Name": "Flauto I",           "Short": "Fl. I",       "Number": "40", "Type": "" },
+  "FlII":      { "Name": "Flauto II",          "Short": "Fl. II",      "Number": "41", "Type": "" },
+  "Ob":                { "Name": "Oboi",               "Short": "Ob.",         "Number": "42", "Type": "" },
+  "ObI":       { "Name": "Oboe I",             "Short": "Ob. I",       "Number": "42", "Type": "" },
+  "ObII":      { "Name": "Oboe II",            "Short": "Ob. II",      "Number": "43", "Type": "" },
+  "Cl":                { "Name": "Clarinetti",         "Short": "Cl.",         "Number": "44", "Type": "" },
+  "ClI":       { "Name": "Clarinetto I",       "Short": "Cl.I",        "Number": "44", "Type": "" },
+  "ClII":      { "Name": "Clarinetto II",      "Short": "Cl.II",       "Number": "45", "Type": "" },
+  "Fag":       { "Name": "Fagotti",            "Short": "Fag.",        "Number": "46", "Type": "" },
+  "FagI":      { "Name": "Fagotto I",          "Short": "Fag. I",      "Number": "46", "Type": "" },
+  "FagII":     { "Name": "Fagotto II",         "Short": "Fag. II",     "Number": "47", "Type": "" },
+  "CFag":      { "Name": "Contrafagotto",      "Short": "Cfag.",       "Number": "48", "Type": "" },
+  "Cor":       { "Name": "Corni",              "Short": "Cor.",        "Number": "50", "Type": "" },
+  "CorI":      { "Name": "Corno I",            "Short": "Cor.I",       "Number": "50", "Type": "" },
+  "CorII":     { "Name": "Corno II",           "Short": "Cor.II",      "Number": "51", "Type": "" },
+  "Trb":       { "Name": "Tromboni",           "Short": "Trb.",        "Number": "54", "Type": "" },
+  "TrbI":      { "Name": "Trombone I",         "Short": "Trb. I",      "Number": "54", "Type": "" },
+  "TrbII":     { "Name": "Trombone II",        "Short": "Trb. II",     "Number": "55", "Type": "" },
+  "TrbIII":    { "Name": "Trombone III",       "Short": "Trb. III",    "Number": "56", "Type": "" },
+  "Tbe":       { "Name": "Trombe",             "Short": "Tbe.",        "Number": "52", "Type": "" },
+  "TbeI":      { "Name": "Tromba I",           "Short": "Tbe.I",       "Number": "52", "Type": "" },
+  "TbeII":     { "Name": "Tromba II",          "Short": "Tbe.II",      "Number": "53", "Type": "" },
+  "Clni":      { "Name": "Clarini",            "Short": "Clni.",       "Number": "52", "Type": "" },
+  "ClnoI":     { "Name": "Clarino I",          "Short": "Clno.I",      "Number": "52", "Type": "" },
+  "ClnoII":    { "Name": "Clarino II",         "Short": "Clno.II",     "Number": "53", "Type": "" },
+  "Tim":       { "Name": "Timpani",            "Short": "Tim.",        "Number": "60", "Type": "" },
+  "V":         { "Name": "Violino",            "Short": "Vl.",         "Number": "30", "Type": "" },
+  "VI":                { "Name": "Violino I",          "Short": "V.I",         "Number": "30", "Type": "" },
+  "VII":       { "Name": "Violino II",         "Short": "V.II",        "Number": "31", "Type": "" },
+  "Va":                { "Name": "Viola",              "Short": "Va.",         "Number": "32", "Type": "" },
+  "VaI":       { "Name": "Viola I",            "Short": "Va.I",        "Number": "32", "Type": "" },
+  "VaII":      { "Name": "Viola II",           "Short": "Va.II",       "Number": "32a","Type": "" },
+  "VaSolo":    { "Name": "Viola Solo",         "Short": "Va.Solo",     "Number": "32a","Type": "" },
+  "VcB":       { "Name": "Violoncello e Contrabbasso", "Short": "Vc. e B.", "Number": "33","Type": "" },
+  "Vc":                { "Name": "Violoncello",        "Short": "Vc.",         "Number": "34", "Type": "" },
+  "Cb":                { "Name": "Basso",              "Short": "B.",          "Number": "35", "Type": "" },
+  "Ch":                { "Name": "Coro",               "Short": "C.",          "Number": "10", "Type": "" },
+  "Singstimme":        { "Name": "Singstimme",                                 "Number": "15", "Type": "" },
+  "S":         { "Name": "Soprano",            "Short": "S.",          "Number": "11", "Type": "" },
+  "A":         { "Name": "Alto",               "Short": "A.",          "Number": "12", "Type": "" },
+  "T":         { "Name": "Tenore",             "Short": "T.",          "Number": "13", "Type": "" },
+  "B":         { "Name": "Basso",              "Short": "B.",          "Number": "14", "Type": "" },
+  "SSolo":     { "Name": "Soprano Solo",       "Short": "S.Solo",      "Number": "16", "Type": "" },
+  "TSolo":     { "Name": "Tenore Solo",        "Short": "A.Solo",      "Number": "17", "Type": "" },
+  "BSolo":     { "Name": "Basso Solo",         "Short": "T.Solo",      "Number": "18", "Type": "" },
+  "ASolo":     { "Name": "Alto Solo",          "Short": "B.Solo",      "Number": "19", "Type": "" },
+  "O":         { "Name": "Organo",             "Short": "Org.",        "Number": "20", "Type": "" },
+  "OI":                { "Name": "Organo I",           "Short": "Org. I",      "Number": "20", "Type": "" },
+  "OII":       { "Name": "Organo II",          "Short": "Org. II",     "Number": "21", "Type": "" },
+  "BC":                { "Name": "Basso Continuo",     "Short": "B.C.",        "Number": "21", "Type": "" },
+  "Organ":     { "Name": "Organo",             "Short": "Org.",        "Number": "20", "Type": "" },
+  "Continuo":  { "Name": "Organo",             "Short": "Org.",        "Number": "21", "Type": "" },
+  "P":         { "Name": "Piano",              "Short": "Pfte.",       "Number": "20a","Type": "" },
+  "Tba":       {                                                       "Number": "57", "Type": "" },
+  "Arpa":      {                                                       "Number": "65", "Type": "" },
+}