#
# source file of the GNU LilyPond music typesetter
#
-# (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+# (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
# Jan Nieuwenhuizen <janneke@gnu.org>
### subst:\(^\|[^._a-z]\)\(abspath\|identify\|warranty\|progress\|warning\|error\|exit\|getopt_args\|option_help_str\|options_help_str\|help\|setup_temp\|read_pipe\|system\|cleanup_temp\|strip_extension\|cp_to_dir\|mkdir_p\|init\) *(
# If set, LILYPONDPREFIX must take prevalence
# if datadir is not set, we're doing a build and LILYPONDPREFIX
-import getopt, os, sys
+import getopt
+import os
+import sys
datadir = '@local_lilypond_datadir@'
if not os.path.isdir (datadir):
datadir = '@lilypond_datadir@'
if __main__.verbose_p:
raise _ ('Exiting (%d)...') % i
else:
- print 'ex thoto' , i
sys.exit (i)
def getopt_args (opts):
str = ''
for s in strs:
- str = str + '%s%s%s\n' % (s[0], ' ' * (w - len(s[0]) + 3), s[1])
+ first = 1
+ for ss in re.split ('\n\s*', s[1]):
+ if first:
+ str = str + '%s%s%s\n' \
+ % (s[0], ' ' * (w - len (s[0]) + 3), ss)
+ first = 0
+ else:
+ str = str + '%s%s\n' \
+ % (' ' * (w + 3), ss)
return str
def help ():
def command_name (cmd):
- # deal with "((latex ) >& 1 ) .." too
+ # deal with "((latex ) >& 1 ) .." too
cmd = re.match ("([\(\)]*)([^ ]*)", cmd).group(2)
- return os.path.split (cmd)[1]
+ return os.path.basename (cmd)
def error_log (name):
name = re.sub('[^a-z]','x', name)
# and thus may break tex run?
'TEXMF' : "{%s,%s}" % (datadir, texmf) ,
- 'GS_FONTPATH' : type1_paths,
- 'GS_LIB' : datadir + '/ps',
+
+ # 'GS_FONTPATH' : type1_paths,
+ # 'GS_LIB' : datadir + '/ps',
+ 'GS_FONTPATH' : "",
+ 'GS_LIB' : "",
}
# $TEXMF is special, previous value is already taken care of
def get_bbox (filename):
bbox = filename + '.bbox'
## -sOutputFile does not work with bbox?
- cmd = 'gs -sDEVICE=bbox -q -dNOPAUSE %s -c quit 2>%s' % \
+ cmd = 'gs -sDEVICE=bbox -q -dNOPAUSE %s -c showpage -c quit 2>%s' % \
(filename, bbox)
system (cmd, progress_p = 1)
box = open (bbox).read ()
header = open (ps_name).read (1024)
- match = re.match (BOUNDING_BOX_RE, header)
+ match = re.search (BOUNDING_BOX_RE, header, re.MULTILINE)
bbox = []
if match:
bbox = map (string.atoi, match.groups ())
if y == 0:
y = 1
- cmd = r'''gs -g%dx%d -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -r%d -dNOPAUSE %s %s -c quit ''' % \
+ cmd = r'''gs -g%dx%d -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -r%d -dNOPAUSE %s %s -c showpage -c quit ''' % \
(x, y, output_file, resolution, trans_ps, ps_name)
rms = glob.glob (base + '-page*.png')
if os.path.isfile (rmfile):
os.unlink (rmfile)
- cmd = r'''gs -s -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -dNOPAUSE -r%d %s -c quit''' % (output_file,
+ cmd = r'''gs -s -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -dNOPAUSE -r%d %s -c showpage -c quit''' % (output_file,
resolution, ps_name)
status = system (cmd)
cmd = r'''gs -s -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=%s -dNOPAUSE -r%d %s -c quit''' % (output_file,
resolution, ps_name)
+ files = glob.glob (re.sub ('%d', '*', output_file))
+ return files
+