From a477744aa3840c850dbe53c2d22bd5a701fe921d Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 21:34:10 +0000 Subject: [PATCH] lilypond-1.0.17 --- make/STATE-VECTOR | 104 ---- scripts/ly2dvi.sh | 1005 -------------------------------------- scripts/ly2dvi32.py | 1117 ------------------------------------------- 3 files changed, 2226 deletions(-) delete mode 100644 make/STATE-VECTOR delete mode 100644 scripts/ly2dvi.sh delete mode 100644 scripts/ly2dvi32.py diff --git a/make/STATE-VECTOR b/make/STATE-VECTOR deleted file mode 100644 index 010ed0a6f9..0000000000 --- a/make/STATE-VECTOR +++ /dev/null @@ -1,104 +0,0 @@ -0.1.76 -0.1.76.jcn1 -0.1.77 -0.1.77.uu1 -0.1.77.hwjc -0.1.77.jcn1 -0.1.77.jcn2 -0.1.77.hwn1 -0.1.78 -0.1.78.hwn1 -0.1.78.jcn1 -0.1.78.jcn2 -0.1.79 -0.1.79.hwn1 -0.1.79.jcn2 -0.1.80 -0.1.80.jcn1 -0.1.80.eb1 -0.1.80.hwn1 -0.1.81 -0.1.81.jcn1 -0.1.81.jbr2 -0.1.81.jcn2 -0.1.81.jbr1 -0.1.81.jcn1 -0.1.81.hwn1 -0.1.81.hwn2 -0.1.82 -0.1.82.jcn1 -0.1.82.jcn2 -0.1.82.jcn3 -0.1.82.jcn4 -0.1.82.jcn5 -0.1.82.hwn1 -0.1.82.hwn2 -0.1.83 -0.1.83.hwn1 -0.1.83.jcn1 -0.1.83.uu1 -0.1.83.hwn1 -0.1.83.hwn2 -0.1.83.hwn3 -0.1.83.hwn4 -0.1.83.hwn5 -0.1.83.jcn4 -0.1.84 -0.1.84.jcn1 -0.1.84.hwn1 -0.1.84.jcn2 -0.1.84.hwn2 -0.1.84.jcn3 -0.1.84.hwn4 -0.1.85 -0.1.85.jcn1 -0.1.85.hwn1 -0.1.85.jcn2 -1.0.0 -1.0.0.hwn1 -1.0.0.hwn2 -1.0.1 -1.0.1.jbr1 -1.0.1.jcn2 -1.0.1.jbr2 -1.0.2 -1.0.2.hwn1 -1.0.3 -1.0.4.jcn1 -1.0.5 -1.0.5.jbr1 -1.0.5.jcn1 -1.0.5.hwn1 -1.0.6 -1.0.6.uu1 -1.0.7 -1.0.7.jbr1 -1.0.7.hwn1 -1.0.7.uu1 -1.0.8.uu1 -1.0.8 -1.0.8.jcn1 -1.0.8.uu1 -1.0.9 -1.0.9.hwn1 -1.0.9.uu1 -1.0.10 -1.0.10.jcn1 -1.0.10.uu1 -1.0.10.uu2 -1.0.11 -1.0.11.mb1 -1.0.11.uu1 -1.0.12 -1.0.12.uu1 -1.0.13 -1.0.13.jcn1 -1.0.13.jcn2 -1.0.13.jcn3 -1.0.13.jcn4 -1.0.13.jcn5 -1.0.14 -1.0.14.hwn1 -1.0.15 -1.0.15.uu1 -1.0.16 diff --git a/scripts/ly2dvi.sh b/scripts/ly2dvi.sh deleted file mode 100644 index 1e7976e24c..0000000000 --- a/scripts/ly2dvi.sh +++ /dev/null @@ -1,1005 +0,0 @@ -#!/bin/sh -# -# Script to make a LaTeX file for Lilypond -# -# Written by Jan Arne Fagertun -# Sat Nov 22 22:26:43 CET 1997 -# -# $Id: ly2dvi.sh,v 1.6 1998/09/15 17:22:43 fred Exp $ -# -# Original LaTeX file made by Mats Bengtsson, 17/8 1997 -# - -VERSION="0.12.jcn1" -NAME=ly2dvi.sh -IDENTIFICATION="$NAME $VERSION" -NOW=`date` -echo "$IDENTIFICATION" 1>&2 - -# TODO: -# prevent orphaned "Lily is here" strings - -# NEWS - -# 0.12.jcn1 -# - mudelaDefs really fixed (sorry, PC) - -# 0.12 -# - -S/--sourcedir switch - -# -#0.11.jcn3 -# - mudelaDefs fixes, (thanks PC) -#0.11.jcn2 -# - pass -I, --include to Lily -# - bf: split $LILYINCLUDE and try all dirs -# - bf: geometry left/top -# -#0.11.pc -# - fix backslash gobbling, reduce number of separate processes used -# - require readable rc files, allow rc file in /usr/local/share/lilypond/lilyrc -# - use latex path, not tex path -# - Don't override if kpsepath returns non-NULL -# - Don't clobber x.tex if it wasn't created by ly2dvi -# -# -#0.11.jcn1 -# - find .fly files too -# -#0.11.hwn1 -# - height vs heigth -# - robustification: give \nonstopmode as LaTeX arg; no hanging if no TeX file. -# - robustification: notice failed cp. - -#0.11 -# - more papersizes (thanks Han-Wen) - don't expect LaTeX to accept all... -# - -W,--Width= : set paper width (points) -# - -H,--Height= : set paper height (points) -# - -H and -W is used only when an unknown papersize is to be specified, -# and has to be combined with a papersize option known to LaTeX -#NB! - -F,--headers= : name of additional LaTeX headers input file. -#NB! Changed from -H to -F -# - -d,--dependencies : passed to lilypond - - -#0.10.jcn1 -# - HEIGHT -> HEIGHT -# - vertical margins (for a4), same on both sides -# - textheight from lilypond output file (mudelapapertextheight) -# - piece titling -# - mudelapiece, mudelaopus -# -#0.10 -# - -K,--keeplilypond : Keep lilypond output files (default delete) -# - -k,--keeply2dvi : Keep ly2dvi output files (default delete) -# - -L,--landscape : Set landscape orientation -# - -N,--nonumber : Turn off page numbering (\pagestyle{empty}) -# - Could not reinsert "\usepackage[T1]{fontenc}" because -# "los-toros" won't work with it -# - Ekstra LaTeX headers from input file -#0.9.hwn1 -# - option to remove output of lily -# 0.9 -# - Trap Lilypond abort -# - Replaced "\usepackage[T1]{fontenc}" with -# \usepackage[latin1]{inputenc} (takk, Mats) -# - Removed "()" around "\LilyIdString" (Janne didn't want it) -# 0.8 - Trap Lilypond segmentation fault -# - Function for cleanup -# - Trap line -# - More human-readable variables -# - Some logics concerning rc-files -# 0.7 -# - Improved Lilypond error checking -# - Output orientation (landscape...). Overrides mudela file -# variable orientation="landscape"; -# - Paper width and height put into variables (only A4!) -# - Adjusted top margin to default..... -# -#TODO -# - Include more papersizes. -# - Manual page....... -# 0.6.jaf2 -# - LILYINCLUDE update -# -# 0.6.hwn1 -# - handle LILYINCLUDE -# - --output -# -# 0.6 -# - Source rc-files, if present. Files are: -# /usr/local/share/lilyrc /etc/lilyrc $HOME/.lilyrc ./.lilyrc -# - tee output from Lilypond -# - Handles margins for A4 paper (equal on both sides) -# - new option -s (--separate) for one LaTeX run per file, -# else all files are run together -# -# 0.5 -# - More useful ("two-level") debug. -# - The Q&D hack to find file names and not handling \include -# is replaced by grabbing output file names from Lilypond. -# = Detects multiple output files - adds them when running -# LaTeX. -# - Works with multiple input files - no matter if they are -# (a mix of) input to or output from Lilypond. -# -#TODO -# - Still no margins handling. -# - We have to discuss how to handle multiple output files -# from Lilypond - 'ly2dvi standchen' gives a rather odd -# result.... - -# 0.4.1 -# - Always exit after printing help info -# 0.4 -# - Changes to ensure for more strict grep'ing of parameters -# Thanks to from G.B.Stott@bolton.ac.uk -# - More efficient use of sed -e 's///' -e 's///' -# Thanks to Johan Vromans and GBS -# - Ask tex for location of titledefs.tex (Thanks to JV) -# - Accept only exact match of "\def\mudelacomposer{" -# (or whatever mudela* defined in titledefs.tex) -# - Even more efficient use of sed (Thanks to JV) -# - Default file name for single output file implemented. -# - Moved help into function - finally included from 0.1.jcn1 -# -#TODO -# - Still doesn't handle \include -# - The Q&D for finding output file name from the sequence of -# \paper \output \midi \output really needs to be looked at. -# I have improved it a lot, but it's only capable of finding -# one (the last) file name. -# Well, I have to rewrite this entirely to handle \include, -# then I can fix it. -# - Still no margins handling. -# -#WARNING -# - Some lines of output from lilypond do NOT start -# at first character position, therefore I have removed "^" -# in sed'ing and grep'ing. - -# 0.3.hwn1 -# - add "Creator: " line to output -# -# 0.3 -# - multiple input files to make score from several files -# (extra files assumed to be Lilypond output) -# - cp dvi-file instead of mv, to allow for xdvi reload -# - check for illegal long options -# - put in pt in text width, if not given -# - put in \nonstopmode in LaTeX file -# - restored LaTeX exit value check - -# 0.2.1 -# - temporarily omit LaTeX exit value check -# - remove ALL temporary files - -# 0.2 -# - fix for solaris - included from 0.1.jcn1 -# - long option hack - included from 0.1.jcn1 - modified -# - moved help into function - NOT included from 0.1.jcn1 yet -# - various improvements - included from 0.1.jcn1 -# - find mudela definitions from titledefs.tex -# - find papersize from lilypond output file (mudelapapersize), -# overridden by option '-p size' or '--papersize=size' -# - option -l lang or --language=lang overrides -# lilypond output file definition (mudelalanguage) -# - textwidth from lilypond output file (mudelapaperlinewidth) - -# 0.1.jcn1 -# - fix for solaris -# - long option hack -# - moved help into function - -# -# Clean up -# -cleanup() { - if [ "$KEEP_LY2DVI_OUTPUT" != "Y" ] - then - [ -n "$LatF" -a -f "$LatF" ] && rm -f $LatF - [ -n "$LOGFILE" -a -f "$LOGFILE" ] && rm -f $LOGFILE - [ -n "$FN" ] && rm -f $FN.* - for F in *$$* $TMP/*$$* - do - rm -f $F - done - fi - if [ "$KEEP_LILY_OUTPUT" != "Y" ] - then - for F in $LILY_OUTPUT_FILES - do - [ -f $F ] && rm -f $F - done - fi -} - -# -# print usage -# -help() { - cat << EOF -Generate dvi file from mudela or lilypond output -Usage: $0 [OPTION]... [FILE]... - -Options: - -D,--debug increase verbosity - -F,--headers= name of additional LaTeX headers file - -H,--Height= set paper height (points) (see manual page) - -I,--include=DIR add DIR to search path of LilyPond - -K,--keeplilypond keep lilypond output files - -L,--landscape set landscape orientation - -N,--nonumber switch off page numbering - -O,--orientation= set orientation (obsolete - use -L instead) - -W,--Width= set paper width (points) (see manual page) - -d,--dependencies tell lilypond make a dependencies file - -h,--help this help text - -k,--keeply2dvi keep ly2dvi output files - -l,--language= give LaTeX language (babel) - -o,--output= set output directory - -p,--papersize= give LaTeX papersize (eg. a4) - -s,--separate run all files separately through LaTeX - -S,--sourcedir set sourcedir - - files may be (a mix of) input to or output from lilypond(1) -EOF -} - - -# -# SVr4 echo swallows backslashes, and there's no way to turn it off. -# Therefore use Echo whenever backslashes may be important. -# printf is in the posix.2 standard -- which means it's in -# all modern shells. -# -Echo() { - printf "%s\n" "$@" -} - -# -setPaperZize() { -case "$PAPERSIZE" in - a0*) - PWIDTH=2389 - PHEIGHT=3381 - PAPERSIZE=a0paper - ;; - a1|a1p*) - PWIDTH=1690 - PHEIGHT=2389 - PAPERSIZE=a1paper - ;; - a2*) - PWIDTH=1194 - PHEIGHT=1690 - PAPERSIZE=a2paper - ;; - a3*) - PWIDTH=845 - PHEIGHT=1194 - PAPERSIZE=a3paper - ;; - a4*) - PWIDTH=597 - PHEIGHT=845 - PAPERSIZE=a4paper - ;; - a5*) - PWIDTH=423 - PHEIGHT=597 - PAPERSIZE=a5paper - ;; - a6*) - PWIDTH=298 - PHEIGHT=423 - PAPERSIZE=a6paper - ;; - a7*) - PWIDTH=211 - PHEIGHT=298 - PAPERSIZE=a7paper - ;; - a8*) - PWIDTH=305 - PHEIGHT=211 - PAPERSIZE=a8paper - ;; - a9*) - PWIDTH=105 - PHEIGHT=305 - PAPERSIZE=a9paper - ;; - a10*) - PWIDTH=74 - PHEIGHT=105 - PAPERSIZE=a10paper - ;; - b0*) - PWIDTH=2847 - PHEIGHT=4023 - PAPERSIZE=b0paper - ;; - b1*) - PWIDTH=2012 - PHEIGHT=2847 - PAPERSIZE=b1paper - ;; - b2*) - PWIDTH=1423 - PHEIGHT=2012 - PAPERSIZE=b2paper - ;; - b3*) - PWIDTH=1006 - PHEIGHT=1423 - PAPERSIZE=b3paper - ;; - b4*) - PWIDTH=712 - PHEIGHT=1006 - PAPERSIZE=b4paper - ;; - b5*) - PWIDTH=503 - PHEIGHT=712 - PAPERSIZE=b5paper - ;; - archA) - PWIDTH=650 - PHEIGHT=867 - ;; - archB) - PWIDTH=867 - PHEIGHT=1301 - ;; - archC) - PWIDTH=1301 - PHEIGHT=1734 - ;; - archD) - PWIDTH=1734 - PHEIGHT=2602 - ;; - archE) - PWIDTH=2602 - PHEIGHT=3469 - ;; - flsa|flse) - PWIDTH=614 - PHEIGHT=940 - ;; - halfletter) - PWIDTH=397 - PHEIGHT=614 - ;; - ledger) - PWIDTH=1229 - PHEIGHT=795 - ;; - legal) - PWIDTH=614 - PHEIGHT=1012 - ;; - letter) - PWIDTH=614 - PHEIGHT=795 - ;; - note) - PWIDTH=542 - PHEIGHT=723 - ;; - *) - echo "" - echo $0": unknown papersize -- "$PAPERSIZE - echo "" - ;; -esac -} - -doRcFiles() -{ -# -# RC-files ? -# -for D in /usr/local/share/ /usr/local/share/lilypond/ /etc/ $HOME/. ./. -do - RCfile=$D"lilyrc" - [ -r $RCfile ] && . $RCfile -done -fORI=$ORIENTATION -fLNG=$LANGUAGE -fPSZ=$PAPERSIZE -fLHF=$LATEXHF -unset ORIENTATION LANGUAGE PAPERSIZE LATEXHF -} - - - -# -# Trap function (cleanup) -# - - - -trap cleanup 0 9 15 - - - -# -# Various defaults -# -[ -z "$TMP" ] && TMP=/tmp -if [ ! -d $TMP ] -then - $debug_echo $IDENTIFICATION": temporary directory "$TMP" not found, set to /tmp" - TMP=/tmp -fi -LOGFILE=$TMP/lilylog.$$ # Logfile for lilypond -PAPERSIZE=a4 # Default papersize name -PWIDTH=597 # Default paperwidth -PHEIGHT=845 # Default paperheight -PNUM="%" # Page numbering on -LILYOPTS="" # Options to lilypond -SOURCEDIR="" -LILYPOND_EXECUTABLE=lilypond -doRcFiles - - - -# Keywords defined in titledefs.tex -# -TF="`kpsewhich -n latex tex titledefs.tex`" -MU_DEF="" -if [ -r "${TF:=/usr/local/share/texmf/tex/lilypond/titledefs.tex}" ] -then - MU_DEF=`sed -n -e 's/.*newcommand\*{.\(mudela[^}]*\)}.*$/\1/p' "$TF"` -fi - -: "${MU_DEF:=mudelatitle mudelasubtitle mudelacomposer \ - mudelameter mudelaopus mudelaarranger mudelapiece \ - mudelapoet mudelainstrument \ - }" - -# -# debugging -# -debug_echo=: -# -# All files in one LaTeX run -# -SEPFILE=N -# -# Find command line options and switches -# -# "x:" x takes argument -# -switches="DF:H:I:KLNO:W:dhkl:o:p:S:s\?" -options="" -# -# ugh, "\-" is a hack to support long options -# while getopts \-:$options$switches O -# must be in double quotes for bash-2.0 -while getopts "\-:$options$switches" O -do - $debug_echo "O: \`$O'" - $debug_echo "arg: \`$OPTARG'" - case $O in - D ) - [ $debug_echo = echo ] && set -x - debug_echo=echo - ;; - F ) - LATEXHF=$OPTARG - ;; - H ) - PHEIGHT=$OPTARG - ;; - I ) - LILYOPTS="$LILYOPTS -I $OPTARG" - LILYINCLUDE="$LILYINCLUDE:$OPTARG" - ;; - K ) - KEEP_LILY_OUTPUT=Y - ;; - L ) - ORIENTATION=landscape - ;; - O ) - ORIENTATION=$OPTARG - ;; - N ) - PNUM="\pagestyle{empty}" - ;; - W ) - PWIDTH=$OPTARG - ;; - d ) - LILYOPTS=$LILYOPTS" -d" - ;; - h ) - help; - exit 0 - ;; - k ) - KEEP_LY2DVI_OUTPUT=Y - ;; - l ) - LANGUAGE=$OPTARG - ;; - o ) - OUTPUTDIR=$OPTARG - ;; - p ) - PAPERSIZE=$OPTARG - ;; - s ) - SEPFILE=Y - ;; - S ) - SOURCEDIR=$OPTARG - ;; - \? ) - help; - exit -1 - ;; - # a long option! - -) - $debug_echo "long option: \`$OPTARG'" - case "$OPTARG" in - He*|-He*) - PHEIGHT"`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`"= - ;; - W*|-W*) - PWIDTH="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`" - ;; - dep*|-dep*) - LILYOPTS="$LILYOPTS -d" - ;; - d*|-d*) - [ $debug_echo = echo ] && set -x - debug_echo=echo - ;; - hea*|-hea*) - LATEXHF="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`" - ;; - h*|-h*) - help; - exit 0 - ;; - i*|-i*) - dir="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`" - LILYOPTS="$LILYOPTS --include=$dir" - LILYINCLUDE="$LILYINCLUDE:$dir" - ;; - keepli*|-keepli*) - KEEP_LILY_OUTPUT=Y - ;; - k*|-k*) - KEEP_LY2DVI_OUTPUT=Y - ;; - land*|-land*) - ORIENTATION=landscape - ;; - lang*|-lang*) - LANGUAGE="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`" - ;; - n*|-n*) - PNUM="\pagestyle{empty}" - ;; - or*|-or*) - ORIENTATION="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`" - ;; - ou*|-ou*) - OUTPUTDIR="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`" - ;; - p*|-p*) - PAPERSIZE="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`" - ;; - separa*|-sep*) - SEPFILE=Y - ;; - sourcedir*|-sourcedir*) - SOURCEDIR=$OPTARG - ;; - *|-*) - echo "$0: illegal option -- \"$OPTARG\"" - help; - exit -1 - ;; - esac - esac -done -shift `expr $OPTIND - 1` - -if [ "$SOURCEDIR" != "" ]; then -# apparently MakeTeXTFM can't handle relative dirs - SOURCEDIR=`cd $SOURCEDIR; pwd` - LILYINCLUDE="$SOURCEDIR/init:$SOURCEDIR/mf/out:$LILYINCLUDE" - TEXINPUTS="$SOURCEDIR/tex:$TEXINPUTS:" - MFINPUTS="$SOURCEDIR/mf:$MFINPUTS:" - LILYPOND_EXECUTABLE="$SOURCEDIR/lily/out/lilypond" - export MFINPUTS LILYPOND_EXECUTABLE TEXINPUTS SOURCEDIR -fi - -# -# Input file name -# -if [ "$1" = "" ] -then - help - $debug_echo "$IDENTIFICATION: No input file name given" - exit 1 -fi -# regexp_quote -- quote a string as a regular expression for egrep or sed -regexp_quote(){ - Echo "$@" | sed 's/\([]\[\.*?+^$]\)/\\\1/g' -} -# -# -mudelaDefs(){ -# Include \def\mudela-definitions -# The aim here is to pick up the definition for the -# current file, then any other file. -# -mudelatmp=$TMP/mudelaDefs$$ -# Use `cat' to prevent filenames being prepended -# -cat "$File" $OF | fgrep "$MU_DEF" > $mudelatmp -for L in $MU_DEF -do - # This converts \def\mudelatitle{fred} - # to \mudelatitle{fred} or to - # \def\mudelatitle{fred} - # and stops after the first one found. - sed -n '/\\def\\'"$L"'{\([^}]*\)}.*$/{ - s//'"`regexp_quote \"$1\"`"'\\'"$L"'{\1}%/p - q - }' $mudelatmp >> $LatF -done -rm -f $mudelatmp -} -# -# -startFile(){ -# -# LaTeX file name -# -BN=`basename "$File" .tex` -FN="$BN.$$" -if [ "$KEEP_LY2DVI_OUTPUT" != "Y" ] -then - LatF="$TMP/$FN.tex" -else - LatF="$FN.tex" -fi -# -# Find: -# paper size (PAPERSIZE, overridden by command line option -p) -# paper orientation (ORIENTATION, overridden by option -o) -# language (LANGUAGE, overridden by option -l) -# textwidth -# -eval `sed -n \\ - -e 's/\\\\def\\\\mudelalanguage{\([^}]*\).*$/fLNG=\1;/p' \\ - -e 's/\\\\def\\\\mudelalatexheaders{\([^}]*\).*$/fLHF=\1;/p' \\ - -e 's/\\\\def\\\\mudelaorientation{\([^}]*\).*$/fORI=\1;/p' \\ - -e 's/\\\\def\\\\mudelapaperlinewidth{\([^}]*\).*$/TWN=\1;/p' \\ - -e 's/\\\\def\\\\mudelapapertextheight{\([^}]*\).*$/THN=\1;/p' \\ - -e 's/\\\\def\\\\mudelapapersize{\([^}]*\).*$/fPSZ=\1;/p' \\ - "$File"` -# -if [ -z "$LATEXHF" ] -then - LATEXHF="$fLHF" -fi -LLHF="%" -if [ -n "$LATEXHF" ] -then - [ -f "$LATEXHF" ] && LLHF="\input{$LATEXHF}" -fi -# -if [ -z "$PAPERSIZE" ] -then - PAPERSIZE="$fPSZ" -fi -if [ -n "$PAPERSIZE" ] -then - setPaperZize - PAPEROPT="$PAPERSIZE" -fi -# -if [ -z "$ORIENTATION" ] -then - ORIENTATION="$fORI" -fi -if [ -n "$ORIENTATION" ] -then - if [ -z "$PAPEROPT" ] - then - PAPEROPT="$ORIENTATION" - else - PAPEROPT="$PAPEROPT,$ORIENTATION" - fi -fi -# -if [ -n "$PAPEROPT" ] -then - PAPER="[$PAPEROPT]" -fi -# -if [ -z "$LANGUAGE" ] -then - LANGUAGE="$fLNG" -fi -if [ -n "$LANGUAGE" ] -then - LLNG="\usepackage[$LANGUAGE]{babel}" -else - LLNG="%" -fi - -# -# Find textwidth -# -if [ -n "$TWN" ] -then - TW="$TWN" - case "$TW" in - *mm) - ;; - *cm) - ;; - *pt) - ;; - *) - TW="${TW}pt" - ;; - esac - $debug_echo "Text width = $TW" -fi -TWp=`Echo $TW | sed -e 's/\..*$//'` -PWp="$PWIDTH" -# -# Find textheight -# -if [ -n "$THN" ] -then - TH=$THN - case $TH in - *mm) - ;; - *cm) - ;; - *pt) - ;; - *) - TH="${TH}pt" - ;; - esac - $debug_echo "Text height = $TH" -fi -THp="`echo $TH | sed -e 's/\..*$//'`" -PHp="$PHEIGHT" -if [ "$ORIENTATION" = "landscape" ] -then - PWp="$PHEIGHT" - PHp="$PWIDTH" -fi -HMARG="`expr '(' $PWp - $TWp ')' / 2`"pt -$debug_echo "Text left = $HMARG" -VMARG="`expr '(' $PHp - $THp ')' / 2`"pt -$debug_echo "Text top = $VMARG" -# -# Geometry: /var/lib/texmf/latex/geometry/geometry.dvi -# -# -# Write LaTeX file -# -cat << EOF > $LatF -% Creator: $IDENTIFICATION -% Automatically generated from $IF, $NOW - -\documentclass$PAPER{article} - -$LLNG -\usepackage{geometry} -\usepackage[latin1]{inputenc} -%\usepackage[T1]{fontenc} -$PNUM -%\addtolength{\oddsidemargin}{-1cm} -%\addtolength{\topmargin}{-1cm} -%\setlength{\textwidth}{$TW} -%\setlength{\textheight}{$TH} -\geometry{width=$TW, left=$HMARG, height=$TH, top=$VMARG} -\input lilyponddefs -\input titledefs -$LLHF -\begin{document} -EOF -mudelaDefs -cat << EOF >> $LatF -\cmrtwenty% ugh -\makelilytitle -EOF -} -nextFile(){ -cat << EOF >> $LatF -\def\theopus{}% -\def\thepiece{}% -\def\mudelaopus{}% -\def\mudelapiece{}% -EOF -mudelaDefs "\\def" -cat << EOF >> $LatF -\def\theopus{\mudelaopus}% ugh -\def\thepiece{\mudelapiece}% -\makelilypiecetitle -EOF -} -# -# Conclusion -# -endFile(){ -cat << EOF >> $LatF -\vfill\hfill{\LilyIdString} -\end{document} -EOF -# -# Run LaTeX -# -latex '\nonstopmode \input '$LatF || exit 5 -# -# Rename dvi file -# -if [ -f $FN.dvi ] -then - RESULT="$BN.dvi" - [ -n "$OUTPUTDIR" ] && RESULT="$OUTPUTDIR/$RESULT" - - cp "$FN.dvi" "$RESULT" || exit 5 -fi -# -# Output some info -# -cat << EOF - -$IDENTIFICATION: dvi file name is $RESULT - -EOF -} - -# ugh. GF is side-effect. -findInput() { -# should check for LILYINCLUDE - OIFS="$IFS" - IFS=':' - x=`echo $LILYINCLUDE | sed "s!:! !g"` - IFS="$OIFS" - for lypath in . $x - do - if [ -f "$lypath/$1" ] - then - GF="$lypath/$1" - return - fi - - if [ -f "$lypath/$1.ly" ] - then - GF="$lypath/$1.ly" - return - fi - if [ -f "$lypath/$1.fly" ] - then - GF="$lypath/$1.fly" - return - fi - done - $debug_echo "$IDENTIFICATION: Input file \"$GF\" not found" - echo "$NAME: Input file \"$GF\" not found" 1>&2 - exit 2 -} -# -# Loop through all files -# - -LILY_OUTPUT_FILES= - -for GF -do - findInput $GF - - # - # Check whether the file is input to or output from lilypond - # - L1=`head -1 $GF` - OP=`echo $L1 | grep "^% Creator: GNU LilyPond"` - if [ -n "$OP" ] - then - # - # OK - it's the output from lilypond. - # - # Get lilypond source file name - # - OF=$GF - IFL=`grep mudelafilename $OF` - if [ "$IFL" != "" ] - then - IF=`echo $IFL | sed -e 's/.*{//' -e 's/}*.$//'` - # - # Check if source file exists - # - if [ ! -f $IF ] - then - $debug_echo $IDENTIFICATION": Mudela file not found." - TW=15.5cm - TH=25.0cm - fi - else - $debug_echo $IDENTIFICATION": Mudela file name not found." - TW=15.5cm - TH=25.0cm - fi - else - # - # I have to assume this is the lilypond input file - # Find output file name, if defined - # - IF=$GF - # - # Run lilypond - # Grab output file names - # - $debug_echo "lilypond "$LILYOPTS $IF - - $LILYPOND_EXECUTABLE $LILYOPTS $IF 2>&1 | tee $LOGFILE - OF="`sed -n -e 's/TeX output to \([^\.]*\.tex\)\.\.\.$/\1/p' $LOGFILE`" - $debug_echo "==> $OF" - LILY_OUTPUT_FILES="$LILY_OUTPUT_FILES $OF" - STATUS=`egrep -i "error|segmentation|abort" $LOGFILE` - echo $STATUS - if [ ! -z "$STATUS" ] - then - exit 10 - fi - fi - # - # "Spin through" all the files - # - for File in $OF - do - $debug_echo "--- "$File - # - # Check if output file is generated - # - if [ ! -f "$File" ] - then - $debug_echo "$IDENTIFICATION: hmm, I could not find the output file $File" - exit 4 - fi - # - # Is this the first file? - # - if [ -z "$FFile" ] - then - FFile="$File" - startFile - else - nextFile - fi - cat << EOF >> $LatF -\input{$File} -EOF - if [ $SEPFILE = Y ] - then - FFile="" - endFile - fi - done -done -if [ $SEPFILE = N ] -then - endFile -fi -# -# OK - finished -# diff --git a/scripts/ly2dvi32.py b/scripts/ly2dvi32.py deleted file mode 100644 index 74c5495c08..0000000000 --- a/scripts/ly2dvi32.py +++ /dev/null @@ -1,1117 +0,0 @@ -#!@PYTHON@ - -""" -======================================================================= -LilyPond to dvi converter - -Features include Title information, paper size specification, and image -orientation. - -Usage: ly2dvi.py [OPTION]... [FILE]... -Input: LilyPond source or LilyPond generated TeX files -Output: DVI file -======================================================================= -""" - -name = 'ly2dvi' -version = '0.0.5' -errorlog = '' - -import sys -import os -import getopt -import re -import string -import time -import glob - - -class Input: - """ - This class handles all ly2dvi.py input file methods - - Public methods: - - __init__() Constructor - open(file) Open a .ly file or .tex file using lilyinclude path - close() Close current file - type() Determine file type .ly (input) or .tex (output) - setVars() Set title definitions found in .tex (output) file - """ - - # - # Constructors - # - - def __init__(this): - this.__fd = None - - # - # open - # - def open(this,file): - """ - 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. - - input: file filename - output: void - error: ExitNotFound Exception - """ - - for i in [''] + Props.get('include')[0:]: - ifile = os.path.join(i,file) - for j in ['','.ly','.fly']: - jfile = ifile+j - try: - this.__fd = open( jfile, 'r' ) - return - except: - pass - sys.exit('ExitNotFound', file) - - - # - # close - # - def close(this): - """ - close file object __fd - - input: void - output: void - error: None - """ - this.__fd.close() - - - # - # type - # - def type(this): - """ - Determine input file type. LilyPond source is 'input' type - and LilyPond generated TeX file is 'output' type - - input: void - output: 'input' | 'output' - error: None - """ - - firstline = this.__fd.readline() - this.__fd.seek(0) - if re.match('% Creator: GNU LilyPond [0-9]+[.0-9]+',firstline ): - return 'output' - else: - return 'source' - - - # - # setVars - # - def setVars(this): - """ - Search for properties in the current input file and set the - appropriate values. The supported properties names are in - local variable varTable along with the property list - titledefs. - - input: void - output: None - error: None - """ - - varTable = [ - # regexp set method - # ------ ---------- - ( 'language', Props.setLanguage ), - ( 'latexheaders', Props.setHeader ), - ( 'orientation', Props.setOrientation ), - ( 'paperpapersize', Props.setPaperZize ), - ( 'papertextheight', Props.setTextHeight ), - ( 'paperlinewidth', Props.setLineWidth ), - ( 'filename', Props.setFilename ), - ] - - titles={} - for line in this.__fd.readlines(): - m=re.match('\\\\def\\\\mudela([\w]+){(.*)}',line) - if m: - for var in varTable: - if m.group(1) == var[0]: - var[1](m.group(2),'file') - break - for var in Props.get('titledefs'): - if m.group(1) == var: - titles[var]=m.group(2) - break - Props.setTitles(titles,'file') - this.__fd.seek(0) - - - -class TeXOutput: - """ - This class handles all ly2dvi.py output file methods - - private methods: - __mudelaDefs(opt) Send title info to output file - - Public methods: - __init__() Constructor - write(str) Write a string to output file - start(file) Start the latex file - next() Process next output file - end() Finish latex file and run latex - """ - - # - # constructor - # - def __init__(this): - this.__fd = None - this.__base = '' - this.__outfile = '' - - # - # __medelaDefs - # - def __mudelaDefs(this,opt): - """ - Write titles to output - - input: opt Supports header and subheader output - output: None - error: None - """ - - titles = Props.get('titles') - for key in titles.keys(): - this.write('%s\\mudela%s{%s}%%\n' % (opt,key,titles[key])) - - # - # write - # - def write(this,str): - """ - Write str to current output file - - input: str String to write - output: None - error: None - """ - - this.__fd.write(str) - - # - # start - # - def start(this,file): - """ - Start LaTeX file. Calculates the horizontal and vertical - margin using pagewidth, pageheight, linewidth, and textheight. - Creates temporary output filename and opens it for write. - Sends the LaTeX header information to output. Lastly sends - the title information to output. - - input: file output file name - output: None - error: None - """ - - now=time.asctime(time.localtime(time.time())) - linewidth = Props.get('linewidth') - textheight = Props.get('textheight') - - if Props.get('orientation') == 'landscape': - pagewidth = Props.get('pageheight') - pageheight = Props.get('pagewidth') - else: - pageheight = Props.get('pageheight') - pagewidth = Props.get('pagewidth') - - horizontalMarginArg = ( (pagewidth - linewidth)/2 ) - verticalMarginArg = ( (pageheight - textheight)/2 ) - - top="""\ -%% Creator: %s -%% Automatically generated from %s, %s - -\\documentclass[%s]{article} - -%s -\\usepackage{geometry} -\\usepackage[latin1]{inputenc} -%%\\usepackage[T1]{fontenc} -%s -%%\\addtolength{\\oddsidemargin}{-1cm} -%%\\addtolength{\\topmargin}{-1cm} -%%\\setlength{\\textwidth}{%s} -%%\\setlength{\\textheight}{%s} -\\geometry{width=%spt, left=%spt, height=%spt, top=%spt} -\\input lilyponddefs -\\input titledefs -%s -\\begin{document} -""" % ( program_id(), Props.get('filename'), now, Props.get('papersize'), - Props.get('language'), Props.get('pagenumber'), linewidth, textheight, - linewidth, horizontalMarginArg, textheight, verticalMarginArg, - Props.get('header') ) - - pathcomp = os.path.splitext(file) - this.__base = pathcomp[0] - this.__outfile = '%s.%d%s' % (pathcomp[0], os.getpid(), pathcomp[1]) - try: - this.__fd = open(this.__outfile,"w") - except: - sys.exit('ExitNoWrite', this.__outfile) - this.write(top) - this.__mudelaDefs('') - this.write("""\ -\\cmrtwenty% ugh -\\makelilytitle -""") - - # - # next - # - def next(this): - """ - Write LaTeX subheader information to support more than one - score in a document. Lastly send current title information to - output. - - input: None - output: None - error: None - """ - - this.write("""\ -\\def\\theopus{}% -\\def\\thepiece{}% -\\def\\mudelaopus{}% -\\def\\mudelapiece{}% -""") - this.__mudelaDefs("\\def") - this.write("""\ -\\def\\theopus{\\mudelaopus}% ugh -\\def\\thepiece{\\mudelapiece}% -\\makelilypiecetitle -""") - - - # - # end - # - def end(this): - """ - Close output file and run latex on it. - - input: None - output: None - error: ExitBadLatex Exception - """ - - outfile=this.__base + '.dvi' - if Props.get('output') != '': - outfile = os.path.join(Props.get('output'), outfile ) - - this.write("""\ -\\vfill\\hfill{\\LilyIdString} -\\end{document} -""") - this.__fd.close() - if ( os.name == 'posix' ): - stat = os.system('latex \'\\nonstopmode \\input %s\'' % - (this.__outfile)) - else: # Windows shells don't eat the single quotes - stat = os.system('latex \\nonstopmode \\input %s' % - (this.__outfile)) - if stat: - sys.exit('ExitBadLatex') - if os.path.isfile(outfile): - os.remove(outfile) - os.rename(this.__base + '.' + str(os.getpid()) + '.dvi', outfile) - sys.stderr.write( '\n' + program_id() + ': dvi file name is %s\n\n' - % (outfile)) - - if Props.get('postscript'): - 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)) - if stat: - sys.exit('ExitBadPostscript') - - - - -class Properties: - """ - This class handles all ly2dvi.py property manipulation - - Public methods: - - __init__() Constructor - set methods - """ - - def __init__(this): - - # - # Following is the order of priority for property assignment. The - # list is organized from lowest to highest priority. Each - # assignment is overridden by the next requester in the list. - # - # Requester Description - # --------- ----------- - # 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 $HOME/.lilyrc - # rcfile ./.lilyrc - # commandline command line arguments - # - this.__overrideTable = { - 'init' : 0, - 'file' : 1, - 'environment' : 2, - 'rcfile' : 3, - 'commandline' : 4, - 'program' : 5 - } - - this.__roverrideTable = {} # reverse lookup used for debug - for i in this.__overrideTable.items(): - this.__roverrideTable[i[1]]=i[0] - - this.__data = { - 'pagewidth' : [597, this.__overrideTable['init']], - 'pageheight' : [845, this.__overrideTable['init']], - 'papersize' : ['a4paper', this.__overrideTable['init']], - 'textheight' : [0, this.__overrideTable['init']], - 'linewidth' : [0, this.__overrideTable['init']], - 'orientation' : ['portrait', this.__overrideTable['init']], - 'language' : ['%', this.__overrideTable['init']], - 'include' : [[], this.__overrideTable['init']], - 'debug' : [0, this.__overrideTable['init']], - 'keeplilypond' : [0, this.__overrideTable['init']], - 'keeply2dvi' : [0, this.__overrideTable['init']], - 'pagenumber' : ['%', this.__overrideTable['init']], - 'separate' : [0, this.__overrideTable['init']], - 'output' : ['', this.__overrideTable['init']], - 'header' : ['%', this.__overrideTable['init']], - 'dependencies' : [0, this.__overrideTable['init']], - 'root' : ['', this.__overrideTable['init']], - 'tmp' : ['d:\tmp', this.__overrideTable['init']], - 'filename' : ['', this.__overrideTable['init']], - 'titledefs' : [[], this.__overrideTable['init']], - 'titles' : [{}, this.__overrideTable['init']], - 'lilyOutputFiles' : [[], this.__overrideTable['init']], - 'postscript' : [0, this.__overrideTable['init']], - } - - # - # Try to set root and HOME first before calling rcfile - # - if os.environ.has_key('LILYPONDPREFIX'): - this.setRoot(os.environ['LILYPONDPREFIX'], 'environment') - else: - p=os.path.split(sys.argv[0]) - p=os.path.split(p[0]) - this.setRoot(p[0],'init') - - if not os.environ.has_key('HOME'): - if os.environ.has_key('HOMEDRIVE') and \ - os.environ.has_key('HOMEPATH'): - os.environ['HOME'] = os.environ['HOMEDRIVE'] + \ - os.environ['HOMEPATH'] - else: - os.environ['HOME'] = os.curdir - - this.rcfile() # Read initialization file(s) - - if os.environ.has_key('LILYINCLUDE'): - tmp=this.get('include') - for s in string.split(os.environ['LILYINCLUDE'],os.pathsep): - tmp.append(s) - this.__set('include', tmp, 'environment') - - - t='' - if os.environ.has_key ('TEXINPUTS'): - t = os.pathsep + os.environ['TEXINPUTS'] - os.environ['TEXINPUTS'] = os.path.join(this.get('root'), 'texmf', - 'tex', 'lilypond' ) + t - - t='' - if os.environ.has_key ('MFINPUTS'): - t = os.pathsep + os.environ['MFINPUTS'] - os.environ['MFINPUTS'] = os.path.join(this.get('root'), 'texmf', - 'mf', 'public', 'lilypond' ) + t - - if os.environ.has_key('TMP'): - this.__set('tmp',os.environ['TMP'],'environment') - - - fd=this.get_texfile_path ('titledefs.tex') - mudefs=[] - - for line in fd.readlines(): - m=re.match('\\\\newcommand\*{\\\\mudela([\w]+)}',line) - if m: - mudefs.append(m.group(1)) - fd.close - this.__set('titledefs', mudefs, 'init') - - # - # __set - # - def __set(this,var,value,requester): - """ - All of the set methods call this to set a property. If the value - was last set by a requestor of lesser priority the new value is - assigned, else the old value has priority and is unchanged. - """ - - if this.__overrideTable[requester] < this.__data[var][1]: - return 0 - else: - this.__data[var] = [value, this.__overrideTable[requester]] - - # - # get - # - def get(this,var): - """ - All of the get methods call this to get a property value. List - variable types are return by value to facilitate an append operation. - """ - - if var == 'include' or var == 'lilyOutputFiles': - return this.__data[var][0][0:] # return a copy not a ref - else: - return this.__data[var][0] - - # - # get_texfile_path - # - def get_texfile_path (this, var): - """ - locate and open titledefs.tex file - """ - - if os.name == 'nt': - path = os.path.join(this.get('root'), 'texmf', 'tex', - 'lilypond', var) - else: - path ='' - cmd =('kpsewhich tex %s %s' % (var,errorlog)) - pipe = os.popen (cmd, 'r') - path = pipe.readline ()[:-1] # chop off \n - return_status = pipe.close() - if return_status and not path: - path = os.path.join(this.get('root'), 'texmf', 'tex', - 'lilypond', var) - fd = open(path, 'r') - return fd - - - # - # Read rc file - # - def rcfile(this): - """ - Read initialization file(s) - """ - varTable = [ - # name set method - # ---- ---------- - ( 'DEBUG', this.setDebug ), - ( 'DEPENDENCIES', this.setDependencies ), - ( 'KEEPLILYPOND', this.setKeeplilypond ), - ( 'KEEPLY2DVI', this.setKeeply2dvi ), - ( 'LANGUAGE', this.setLanguage ), - ( 'LATEXHF', this.setHeader ), - ( 'LILYINCLUDE', this.setInclude ), - ( 'LILYPONDPREFIX', this.setRoot ), - ( 'NONUMBER', this.setNonumber ), - ( 'ORIENTATION', this.setOrientation ), - ( 'OUTPUTDIR', this.setOutput ), - ( 'PAPERSIZE', this.setPaperZize ), - ( 'PHEIGHT', this.setTextHeight ), - ( 'POSTSCRIPT', this.setPostscript ), - ( 'PWIDTH', this.setLineWidth ), - ( 'SEPARATE', this.setSeparate ), - ( 'TMP', this.setTmp ), - ] - - if ( os.name == 'posix' ): - dotFilename='.lilyrc' - else: # Windows apps like edit choke on .lilyrc - dotFilename='_lilyrc' - - for d in [os.path.join(this.get('root'),'share','lilypond'), \ - os.environ['HOME'], os.curdir ]: - file=os.path.join(d,dotFilename) - try: - fd = open( file, 'r' ) - except: - continue - - for line in fd.readlines(): - if re.match('#.*',line): - continue - m=re.search('([\w]+)=(.*)',line) - if m: - for var in varTable: - if m.group(1) == var[0]: - var[1](m.group(2),'rcfile') - break - fd.close - - # - # setPaperZize - # - def setPaperZize(this,size,requester): - """ - Set paper size properties - """ - - paperTable = [ - # regex width height name - # ----- ----- ------ ---- - ( 'a0.*', 2389, 3381, 'a0paper' ), - ( 'a1$|a1p.*', 1690, 2389, 'a1paper' ), - ( 'a2.*', 1194, 1690, 'a2paper' ), - ( 'a3.*', 845, 1194, 'a3paper' ), - ( 'a4.*', 597, 845, 'a4paper' ), - ( 'a5.*', 423, 597, 'a5paper' ), - ( 'a6.*', 298, 423, 'a6paper' ), - ( 'a7.*', 211, 298, 'a7paper' ), - ( 'a8.*', 305, 211, 'a8paper' ), - ( 'a9.*', 105, 305, 'a9paper' ), - ( 'a10.*', 74, 105, 'a10paper' ), - ( 'b0.*', 2847, 4023, 'b0paper' ), - ( 'b1.*', 2012, 2847, 'b1paper' ), - ( 'b2.*', 1423, 2012, 'b2paper' ), - ( 'b3.*', 1006, 1423, 'b3paper' ), - ( 'b4.*', 712, 1006, 'b4paper' ), - ( 'b5.*', 503, 712, 'b5paper' ), - ( 'archA$', 650, 867, 'archApaper' ), - ( 'archB$', 867, 1301, 'archBpaper' ), - ( 'archC$', 1301, 1734, 'archCpaper' ), - ( 'archD$', 1734, 2602, 'archDpaper' ), - ( 'archE$', 2602, 3469, 'archEpaper' ), - ( 'flsa$|flse$', 614, 940, 'flsapaper' ), - ( 'halfletter$', 397, 614, 'halfletterpaper' ), - ( 'ledger$', 1229, 795, 'ledgerpaper' ), - ( 'legal$', 614, 1012, 'legalpaper' ), - ( 'letter$', 614, 795, 'letterpaper' ), - ( 'note$', 542, 723, 'notepaper' ) - ] - - found=0 - for paper in paperTable: - if re.match(paper[0],size): - found=1 - this.__set('pagewidth',paper[1],requester) - this.__set('pageheight',paper[2],requester) - this.__set('papersize',paper[3],requester) - break - - if not found: - sys.exit('ExitBadPaper',size) - - # - # setTextHeight - # - def setTextHeight(this,size,requester): - """ - Set textheight property - """ - - m=re.match('([0-9][.0-9]*)(cm|mm|pt|$)',size) - if m: - if m.group(2) == 'cm': - this.__set('textheight',\ - float(m.group(1)) * 72.27/2.54, requester ) - elif m.group(2) == 'mm': - this.__set('textheight',\ - float(m.group(1)) * 72.27/25.4, requester ) - elif m.group(2) == 'pt': - this.__set('textheight', float(m.group(1)), requester ) - elif m.group(2) == '': - this.__set('textheight', float(m.group(1)), requester ) - else: - sys.exit('ExitBadHeight', m.group(2)) - else: - sys.exit('ExitBadHeight', size) - - # - # setLineWidth - # - def setLineWidth(this,size,requester): - """ - Set linewidth propery - """ - - m=re.match('([0-9][.0-9]*)(cm|mm|pt|$)',size) - if m: - if m.group(2) == 'cm': - this.__set('linewidth', \ - float(m.group(1)) * 72.27/2.54, requester ) - elif m.group(2) == 'mm': - this.__set('linewidth', \ - float(m.group(1)) * 72.27/25.4, requester ) - elif m.group(2) == 'pt': - this.__set('linewidth', float(m.group(1)), requester ) - elif m.group(2) == '': - this.__set('linewidth', float(m.group(1)), requester ) - else: - sys.exit('ExitBadWidth', m.group(2)) - else: - sys.exit('ExitBadWidth', size) - - # - # setOrientation - # - def setOrientation(this,orient,requester): - """ - Set orientation property - """ - - if orient == 'landscape' or orient == 'portrait': - this.__set('orientation', orient, requester ) - else: - sys.exit('ExitBadOrient', orient) - - # - # setLanguage - # - def setLanguage(this,lang,requester): - """ - Set language property - """ - - this.__set('language', '\\usepackage[%s]{babel}' % (lang), requester ) - - # - # setInclude - # - def setInclude(this,inc, requester): - """ - Append an include path - """ - - tmp = this.get('include') - tmp.append(inc) - this.__set('include', tmp, requester ) - - # - # setDebug - # - def setDebug(this,value,requester): - """ - Set or Clear debug flag - """ - - if int(value) == 1: - this.__set('debug',1,requester) - else: - this.__set('debug',0,requester) - - # - # setKeeplilypond - # - def setKeeplilypond(this, value, requester): - """ - Set or Clear keeplilypond flag - """ - - if int(value) == 1: - this.__set('keeplilypond',1,requester) - else: - this.__set('keeplilypond',0,requester) - - # - # setKeeply2dvi - # - def setKeeply2dvi(this, value, requester): - """ - Set or Clear keeply2dvi flag - """ - - if int(value) == 1: - this.__set('keeply2dvi',1,requester) - else: - this.__set('keeply2dvi',0,requester) - - # - # setNonumber - # - def setNonumber(this, value, requester): - """ - Set nonumber flag - """ - - if int(value) == 1: - this.__set('pagenumber',1,requester) - else: - this.__set('pagenumber',0,requester) - - # - # setSeparate - # - def setSeparate(this, value, requester): - """ - Set or Clear separate flag - """ - - if int(value) == 1: - this.__set('separate',1,requester) - else: - this.__set('separate',0,requester) - - # - # Set output directory name - # - def setOutput(this,out,requester): - this.__set('output',out,requester) - - # - # Set latex header name - # - def setHeader(this,head, requester): - this.__set('header',head,requester) - - # - # Set or Clear Dependencies flag to generate makefile dependencies - # - def setDependencies(this, requester): - """ - Set or Clear dependencies flag - """ - - if int(value) == 1: - this.__set('dependencies',1,requester) - else: - this.__set('dependencies',0,requester) - - # - # Set tmp directory - # - def setTmp(this,dir, requester): - this.__set('tmp',dir,requester) - - # - # Set mudela source file name - # - def setFilename(this,file, requester): - this.__set('filename',file,requester) - - # - # Set title commands - # - def setTitles(this,titles, requester): - this.__set('titles',titles,requester) - - # - # Set title commands - # - def addLilyOutputFiles(this,filelist,requester): - """ - Add a to the lily output list - """ - - tmp = this.get('lilyOutputFiles') - tmp = tmp + filelist - this.__set('lilyOutputFiles',tmp,requester) - - # - # Set/Clear postscript flag - # - def setPostscript(this,value,requester): - """ - Set postscript flag - """ - - if int(value) == 1: - this.__set('postscript',1,requester) - else: - this.__set('postscript',0,requester) - - # - # Set root - # - def setRoot(this,path, requester): - """ - Set lilypond root directory - """ - - os.environ['LILYPONDPREFIX'] = path - this.__set('root',path,requester) - - # - # printProps - # - def printProps(this): - """ - Print properties - """ - - for key in this.__data.keys(): - print "%s <%s>:<%s>" % (key,this.get(key), - this.__roverrideTable[this.__data[key][1]]) - - - -# -# Misc functions -# - -def getLilyopts(): - inc = '' - if len(Props.get('include')) > 0: - inc = '-I ' + string.join(Props.get('include'),os.pathsep) - else: - - if Props.get('dependencies'): - dep=' -d' - else: - dep='' - return inc + dep - return inc - -def writeLilylog(contents): - if Props.get('keeplilypond'): - file='lilylog.' + str(os.getpid()) - output = Props.get('output') - if output != '': - file = os.path.join( output, file ) - try: - fd = open( file, 'w' ) - except: - sys.exit('ExitNoWrite', file) - fd.write(contents) - fd.close() - -def getTeXFile(contents): - texfiles=[] - for line in string.split(contents,'\n'): - m = re.search('^TeX output to (.+)\.\.\.', line) - if m: - texfiles.append(m.group(1)) - - if texfiles == []: - sys.exit('ExitNoTeXName') - else: - return texfiles - -def program_id (): - return name + ' ' + version; - - -def mailaddress(): - try: - return os.environ['MAILADDRESS'] - except KeyError: - return '(address unknown)' - - -def identify (): - sys.stderr.write (program_id () + '\n') - -def help (): - sys.stderr.write ( - 'Generate dvi file from mudela or lilypond output\n' - 'Usage: ' + name + ' [OPTION]... [FILE]...\n' - '\n' - 'Options:\n' - ' -D,--debug increase verbosity\n' - ' -F,--headers= name of additional LaTeX headers file\n' - ' -H,--Height= set paper height (points) (see manual page)\n' - ' -I,--include=DIR add DIR to LilyPond\'s search path\n' - ' -K,--keeplilypond keep lilypond output files\n' - ' -L,--landscape set landscape orientation\n' - ' -N,--nonumber switch off page numbering\n' - ' -O,--orientation= set orientation (obsolete - use -L instead)\n' - ' -P,--postscript generate postscript file\n' - ' -W,--Width= set paper width (points) (see manual page)\n' - ' -d,--dependencies tell lilypond make a dependencies file\n' - ' -h,--help this help text\n' - ' -k,--keeply2dvi keep ly2dvi output files\n' - ' -l,--language= give LaTeX language (babel)\n' - ' -o,--output= set output directory\n' - ' -p,--papersize= give LaTeX papersize (eg. a4)\n' - ' -s,--separate run all files separately through LaTeX\n' - '\n' - 'files may be (a mix of) input to or output from lilypond(1)\n' - ) - - - -# -# main -# - -def main(): - """Generate dvi files from lilypond source/output""" - - infile = Input() - outfile = TeXOutput() - texInputFiles=[] - - (options, files) = getopt.getopt (sys.argv[1:], - 'DF:H:I:KLNPW:dhkl:o:p:s', - ['debug', 'headers=', 'Height=', - 'include=', 'keeplilypond', 'landscape', - 'nonumber', 'Width=', 'dependencies', - 'help', 'keeply2dvi', 'language=', - 'output=', 'papersize=', 'separate', - 'postscript']) - for opt in options: - o = opt[0] - a = opt[1] - if o == '--debug' or o == '-D': - Props.setDebug(1,'commandline') - elif o == '--headers' or o == '-F': - Props.setHeader(a,'commandline') - elif o == '--include' or o == '-I': - Props.setInclude(a,'commandline') - elif o == '--Height' or o == '-H': - Props.setTextHeight(a,'commandline') - elif o == '--keeplilypond' or o == '-K': - Props.setKeeplilypond(1,'commandline') - elif o == '--landscape' or o == '-L': - Props.setOrientation('landscape','commandline') - elif o == '--nonumber' or o == '-N': - Props.setNonumber('commandline') - elif o == '--Width' or o == '-W': - Props.setLineWidth(a,'commandline') - elif o == '--dependencies' or o == '-d': - Props.setDependencies(1,'commandline') - elif o == '--help' or o == '-h': - help() - return 0 - elif o == '--keeply2dvi' or o == '-k': - Props.setKeeply2dvi(1,'commandline') - elif o == '--language' or o == '-l': - Props.setLanguage(a,'commandline') - elif o == '--output' or o == '-o': - Props.setOutput(a,'commandline') - elif o == '--papersize' or o == '-p': - Props.setPaperZize(a,'commandline') - elif o == '--separate' or o == '-s': - Props.setSeparate(1,'commandline') - elif o == '--postscript' or o == '-P': - Props.setPostscript(1,'commandline') - - if len(files): - for file in files: - infile.open(file) - type = infile.type() - infile.close() - if type == 'source': - cmd = 'lilypond %s %s 2>&1' % (getLilyopts(), file) - fd = os.popen( cmd , 'r' ) - log = '' - line=fd.readline() - while line: - log = log + line - sys.stderr.write( line ) - line=fd.readline() - stat = fd.close() - if stat: - sys.exit('ExitBadLily', cmd ) - texFiles=getTeXFile(log) - writeLilylog(log) - Props.addLilyOutputFiles(texFiles,'program') - texInputFiles = texInputFiles + texFiles - else: - texInputFiles.append(file) - - firstfile=1 - for file in texInputFiles: - infile.open(file) - infile.setVars() # first pass set variables - infile.close() - if Props.get('debug'): - Props.printProps() - if firstfile: - outfile.start(file) - else: - outfile.next() - outfile.write("""\ -\\input{%s} -""" % (file)) - if Props.get('separate'): - outfile.end() - else: - firstfile=0 - if not Props.get('separate'): - outfile.end() - else: - help() - sys.exit('ExitBadArgs','No files specified') - -# -# Exit values -# -ExitTable = { - 'ExitInterupt' : ['Ouch!', 1 ], - 'ExitBadArgs' : ['Wrong number of arguments', 2 ], - 'ExitNotFound' : ['File not found', 3 ], - 'ExitBadPaper' : ['Unknown papersize', 4 ], - 'ExitBadHeight' : ['Invalid Height specification', 5 ], - 'ExitBadWidth' : ['Invalid Width specification', 6 ], - 'ExitBadOrient' : ['Invalid Orientation specification', 7 ], - 'ExitNoWrite' : ['Permission denied', 8 ], - 'ExitNoTeXName' : ['hmm, I could not find an output file name', 9 ], - 'ExitBadLily' : ['Lilypond failed', 10 ], - 'ExitBadLatex' : ['Latex failed', 11 ], - 'ExitBadPostscript' : ['Postscript failed', 12 ], - 'ExitUnknown' : ['Unknown Exit Code', 20 ], - } - -def cleanup(): - lilyfiles = [] - tmpfiles = [] - if not Props.get('keeplilypond'): - lilyfiles = Props.get('lilyOutputFiles') - if not Props.get('keeply2dvi'): - tmpfiles = glob.glob('*.' + str(os.getpid()) + '.*' ) - for file in lilyfiles + tmpfiles: - if os.path.isfile(file): - os.remove(file) - - -identify() -Props = Properties() - -try: - main() - -except KeyboardInterrupt: - print ExitTable['ExitInterupt'][0] - cleanup() - sys.exit(ExitTable['ExitInterupt'][1]) - -except SystemExit, errno: - if ExitTable.has_key(errno.args[0]): - msg = ExitTable[errno.args[0]] - else: - msg = ExitTable['ExitUnknown'] - if len(errno.args) > 1: - sys.stderr.write( '%s: %s: %s\n' % (name, msg[0], errno.args[1])) - else: - sys.stderr.write( '%s %s\n' % (name, msg[0])) - if Props.get('debug'): - Props.printProps() - cleanup() - sys.exit(msg[1]) -else: - cleanup() -- 2.39.5