"""
name = 'ly2dvi'
-version = '0.0.6'
+version = '0.0.11'
errorlog = ''
import sys
open file and set private class variable __fd. The search
sequence is: current directory followed by the directories
found in include property list. Each directory is searched
- for file, file.ly, and file.fly.
+ for file, file.ly, file.sly and file.fly.
input: file filename
output: void
for i in [''] + Props.get('include')[0:]:
ifile = os.path.join(i,file)
- for j in ['','.ly','.fly']:
+ for j in ['','.ly','.fly', '.sly']:
jfile = ifile+j
try:
this.__fd = open( jfile, 'r' )
firstline = this.__fd.readline()
this.__fd.seek(0)
- if re.match('% Creator: GNU LilyPond [0-9]+[.0-9]+',firstline ):
+ if re.match('%created by: GNU LilyPond [0-9]+[.0-9]+',firstline ):
return 'output'
else:
return 'source'
else:
pageheight = Props.get('pageheight')
pagewidth = Props.get('pagewidth')
-
+
horizontalMarginArg = ( (pagewidth - linewidth)/2 )
verticalMarginArg = ( (pageheight - textheight)/2 )
outfile = os.path.join(Props.get('output'), outfile )
this.write("""\
-\\vfill\\hfill{\\LilyIdString}
+\\vfill\\hfill{\\mudelatagline}
\\end{document}
""")
this.__fd.close()
psoutfile=this.__base + '.ps'
if Props.get('output') != '':
psoutfile = os.path.join(Props.get('output'), psoutfile )
- stat = os.system('dvips -o %s %s 2>&1' % (psoutfile,outfile))
+ stat = os.system('dvips -o %s %s' % (psoutfile,outfile))
if stat:
sys.exit('ExitBadPostscript')
# init Initial default values
# file The values found in the lilypond generated TeX files
# environment Envrionment variables LILYINCLUDE, LILYPONDPREFIX
- # rcfile $LILYPONDPREFIX/share/lilypond/.lilyrc
+ # rcfile $LILYPONDPREFIX/.lilyrc
# rcfile $HOME/.lilyrc
# rcfile ./.lilyrc
# commandline command line arguments
'pageheight' : [845, this.__overrideTable['init']],
'papersize' : ['a4paper', this.__overrideTable['init']],
'textheight' : [0, this.__overrideTable['init']],
- 'linewidth' : [0, this.__overrideTable['init']],
+ 'linewidth' : [500, this.__overrideTable['init']],
'orientation' : ['portrait', this.__overrideTable['init']],
'language' : ['%', this.__overrideTable['init']],
'include' : [[], this.__overrideTable['init']],
else:
p=os.path.split(sys.argv[0])
p=os.path.split(p[0])
- this.setRoot(p[0],'init')
+ # bit silly. for ly2dvi, overrules compiled-in datadir...
+ # how to do this better (without running lily, of course?
+ this.setRoot(os.path.join(p[0],'share','lilypond'), 'init')
if not os.environ.has_key('HOME'):
if os.environ.has_key('HOMEDRIVE') and \
this.__set('include', tmp, 'environment')
- t=''
+ t= os.pathsep
if os.environ.has_key ('TEXINPUTS'):
- t = os.pathsep + os.environ['TEXINPUTS']
- os.environ['TEXINPUTS'] = os.path.join(this.get('root'), 'share',
- 'lilypond', 'tex' ) + t
+ t = os.environ['TEXINPUTS'] + os.pathsep
+ os.environ['TEXINPUTS'] = t + \
+ os.path.join(this.get('root'), 'tex' ) + \
+ os.pathsep + os.path.join(this.get('root'), 'ps' )
t=''
if os.environ.has_key ('MFINPUTS'):
- t = os.pathsep + os.environ['MFINPUTS']
- os.environ['MFINPUTS'] = os.path.join(this.get('root'), 'share',
- 'lilypond', 'mf' ) + t
+ t = os.environ['MFINPUTS']
+ os.environ['MFINPUTS'] = os.pathsep + t + \
+ os.path.join(this.get('root'), 'mf')
if os.environ.has_key('TMP'):
this.__set('tmp',os.environ['TMP'],'environment')
"""
if os.name == 'nt':
- path = os.path.join(this.get('root'), 'share', 'lilypond',
- 'tex', var)
+ path = os.path.join(this.get('root'), 'tex', var)
else:
path =''
cmd =('kpsewhich tex %s %s' % (var,errorlog))
path = pipe.readline ()[:-1] # chop off \n
return_status = pipe.close()
if return_status and not path:
- path = os.path.join(this.get('root'), 'share', 'lilypond',
- 'tex', var)
+ path = os.path.join(this.get('root'), 'tex', var)
fd = open(path, 'r')
return fd
else: # Windows apps like edit choke on .lilyrc
dotFilename='_lilyrc'
- for d in [os.path.join(this.get('root'),'share','lilypond','ly'), \
+ for d in [os.path.join(this.get('root'),'ly'), \
os.environ['HOME'], os.curdir ]:
file=os.path.join(d,dotFilename)
try:
else:
sys.exit('ExitBadWidth', m.group(2))
else:
- sys.exit('ExitBadWidth', size)
+ sys.stderr.write ('ly2dvi: warning: ignoring linewidth: ' + size + '\n')
#
# setOrientation
def getLilyopts():
inc = ''
if len(Props.get('include')) > 0:
- inc = '-I ' + string.join(Props.get('include'),os.pathsep)
+ inc = string.join (map (lambda x: '-I "%s"' % x, Props.get('include')))
else:
if Props.get('dependencies'):
type = infile.type()
infile.close()
if type == 'source':
- cmd = 'lilypond %s %s 2>&1' % (getLilyopts(), file)
- fd = os.popen( cmd , 'r' )
+ if os.environ.has_key('OS') and \
+ os.environ['OS'] == 'Windows_95':
+ cmd = 'ash -c "lilypond %s %s 2>&1"' %(getLilyopts(), file)
+ else:
+ cmd = 'lilypond %s %s 2>&1' % (getLilyopts(), file)
+ sys.stderr.write ('executing: %s\n'% cmd)
+
+ fd = os.popen(cmd , 'r')
log = ''
- line=fd.readline()
- while line:
- log = log + line
- sys.stderr.write( line )
- line=fd.readline()
+
+ s = fd.readline()
+ while len(s) > 0:
+ sys.stderr.write (s)
+ sys.stderr.flush ()
+ log = log + s
+ s = fd.readline ()
+ if 0:
+ s = fd.read (1)
+ while len(s) > 0:
+ sys.stderr.write (s)
+ sys.stderr.flush ()
+ s = fd.read (1)
+ log = log + s
stat = fd.close()
if stat:
sys.exit('ExitBadLily', cmd )