if not self.m_use_geometry:
return latex_linewidths[self.m_papersize][self.m_fontsize]
else:
- geo_opts = (a == None, b == None, c == None)
-
+ geo_opts = (self.m_geo_lmargin == None,
+ self.m_geo_width == None,
+ self.m_geo_rmargin == None)
+
if geo_opts == (1, 1, 1):
if self.m_geo_textwidth:
return self.m_geo_textwidth
optstring = string.join (opts, ' ')
optstring = re.sub ('\n', ' ', optstring)
body = r"""
-%% Generated by lilypond-book.py; options are %s %%ughUGH not original options
+%% Generated automatically by: lilypond-book.py
+%% options are %s %%ughUGH not original options
\include "paper%d.ly"
\paper { linewidth = %f \pt; }
""" % (optstring, music_size, l) + body
(type, body, opts) = chunk
assert type == 'lilypond'
file_body = compose_full_body (body, opts)
- basename = `abs(hash (file_body))`
+ basename = 'lily-' + `abs(hash (file_body))`
for o in opts:
m = re.search ('filename="(.*?)"', o)
if m:
return st
def compile_all_files (chunks):
+ global foutn
eps = []
tex = []
png = []
x = os.path.join (g_here_dir, x)
return ' -I %s' % x
- incs = map (incl_opt, include_path)
+ incs = map (incl_opt, include_path)
lilyopts = string.join (incs, ' ' )
+ if do_deps:
+ lilyopts = lilyopts + ' --dependencies '
+ if g_outdir:
+ lilyopts = lilyopts + '--dep-prefix=' + g_outdir + '/'
texfiles = string.join (tex, ' ')
system ('lilypond --header=texidoc %s %s' % (lilyopts, texfiles))
+
+ #
+ # Ugh, fixing up dependencies for .tex generation
+ #
+ if do_deps:
+ depfiles=map (lambda x: re.sub ('(.*)\.ly', '\\1.dep', x), tex)
+ for i in depfiles:
+ text=open (i).read ()
+ text=re.sub ('\n([^:\n]*):', '\n' + foutn + ':', text)
+ open (i, 'w').write (text)
+
for e in eps:
system(r"tex '\nonstopmode \input %s'" % e)
system(r"dvips -E -o %s %s" % (e + '.eps', e))
cmd = r"""gs -sDEVICE=pgm -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=- -r90 -dNOPAUSE %s -c quit | pnmcrop | pnmtopng > %s"""
cmd = cmd % (g + '.eps', g + '.png')
system (cmd)
- if g_outdir:
- os.chdir(d)
+ os.chdir (d)
def update_file (body, name):
sys.exit (0)
-def write_deps (fn, target):
- sys.stdout.write('writing `%s\'\n' % os.path.join(g_outdir, fn))
+def write_deps (fn, target, chunks):
+ global read_files
+ sys.stdout.write('Writing `%s\'\n' % os.path.join(g_outdir, fn))
f = open (os.path.join(g_outdir, fn), 'w')
f.write ('%s%s: ' % (g_dep_prefix, target))
- for d in __main__.read_files:
+ for d in read_files:
f.write ('%s ' % d)
+ basenames=[]
+ for c in chunks:
+ if c[0] == 'lilypond':
+ (type, body, opts, todo, basename) = c;
+ basenames.append (basename)
+ for d in basenames:
+ if g_outdir:
+ d=g_outdir + '/' + d
+ if g_dep_prefix:
+ #if not os.isfile (d): # thinko?
+ if not re.search ('/', d):
+ d = g_dep_prefix + d
+ f.write ('%s.tex ' % d)
+ f.write ('\n')
+ #if len (basenames):
+ # for d in basenames:
+ # f.write ('%s.ly ' % d)
+ # f.write (' : %s' % target)
f.write ('\n')
f.close ()
- __main__.read_files = []
+ read_files = []
def identify():
sys.stdout.write ('lilypond-book (GNU LilyPond) %s\n' % program_version)
return newchunks
+foutn=""
def do_file(input_filename):
+ global foutn
file_settings = {}
if outname:
my_outname = outname
scan_preamble(chunks)
chunks = process_lilypond_blocks(my_outname, chunks)
+ foutn = os.path.join (g_outdir, my_outname + '.' + format)
+
# Do It.
if __main__.g_run_lilypond:
compile_all_files (chunks)
x = 0
chunks = completize_preamble (chunks)
- foutn = os.path.join(g_outdir, my_outname + '.' + format)
sys.stderr.write ("Writing `%s'\n" % foutn)
fout = open (foutn, 'w')
for c in chunks:
# should chmod -w
if do_deps:
- write_deps (my_depname, foutn)
+ write_deps (my_depname, foutn, chunks)
outname = ''