]> git.donarmstrong.com Git - lilypond.git/blob - scripts/auxiliar/prepare-web-media.py
Add '-dcrop' option to ps and svg backends
[lilypond.git] / scripts / auxiliar / prepare-web-media.py
1 #!/usr/bin/env python
2
3 import os
4 import sys
5 import glob
6 import shutil
7
8 try:
9     lilypond_git_dir = os.environ["LILYPOND_GIT"]
10     lilypond_web_media_dir = os.environ["LILYPOND_WEB_MEDIA_GIT"]
11 except KeyError:
12     print "Error: you must have these environment variables defined:"
13     print "  $LILYPOND_GIT"
14     print "  $LILYPOND_WEB_MEDIA_GIT"
15     sys.exit(1)
16
17 build_dir = os.path.join(lilypond_git_dir, 'build')
18
19 def get_pictures_from(dirname):
20     try:
21         examine_dirname = os.path.join(build_dir,
22             "Documentation", dirname, "out-www")
23         filenames = (
24             glob.glob(os.path.join(examine_dirname, "*.png")) +
25             glob.glob(os.path.join(examine_dirname, "*.jpg")))
26     except:
27         print "Cannot find files (maybe a problem with your build directory?)"
28     return filenames
29
30 pictures_filenames = get_pictures_from("pictures")
31 ly_examples_filenames = get_pictures_from(os.path.join("web", "ly-examples"))
32
33 pictures_dest = os.path.join(lilypond_web_media_dir, "pictures")
34 ly_examples_dest = os.path.join(lilypond_web_media_dir, "ly-examples")
35 for filename in pictures_filenames:
36     shutil.copy(filename, pictures_dest)
37 for filename in ly_examples_filenames:
38     shutil.copy(filename, ly_examples_dest)
39
40 print "Finished copying."
41 print "Don't forget to git commit and push to the lilypond-web-media repository!"
42