X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fbuild%2Flys-to-tely.py;h=a3bc4b576bdc8e08f4bc9ff0f9e2dbbe42147c53;hb=569714401fbe0e814f0282059f157aa36a54c706;hp=4b2e232053e8b6504f6f923df6d39ecabc10bbe9;hpb=a066a93ee74edebb9d238a1bac93c3bc7e8e6e4a;p=lilypond.git diff --git a/scripts/build/lys-to-tely.py b/scripts/build/lys-to-tely.py index 4b2e232053..a3bc4b576b 100644 --- a/scripts/build/lys-to-tely.py +++ b/scripts/build/lys-to-tely.py @@ -6,6 +6,7 @@ TODO: * Add @nodes, split at sections? + * -o --output listed in help is not implemented?! ''' @@ -13,6 +14,7 @@ import sys import os import getopt import re +import glob program_name = 'lys-to-tely' @@ -26,6 +28,8 @@ Options: -f, --fragment-options=OPTIONS use OPTIONS as lilypond-book fragment options -o, --output=NAME write tely doc to NAME + -i, --input-filenames=NAME read list of files from a file instead of stdin + -g, --glob-input=GLOB a string which will be passed to glob.glob(GLOB) -t, --title=TITLE set tely doc title TITLE -a, --author=AUTHOR set tely author AUTHOR --template=TEMPLATE use TEMPLATE as Texinfo template file, @@ -39,11 +43,15 @@ def help (text): sys.exit (0) (options, files) = getopt.getopt (sys.argv[1:], 'f:hn:t:', - ['fragment-options=', 'help', 'name=', 'title=', 'author=', 'template=']) + ['fragment-options=', 'help', 'name=', + 'title=', 'author=', 'template=', + 'input-filenames=', 'glob-input=']) name = "ly-doc" title = "Ly Doc" author = "Han-Wen Nienhuys and Jan Nieuwenhuizen" +input_filename = "" +glob_input = "" template = '''\input texinfo @setfilename %%(name)s.info @settitle %%(title)s @@ -83,6 +91,10 @@ for opt in options: title = a elif o == '-a' or o == '--author': author = a + elif o == '-i' or o == '--input-filenames': + input_filename = a + elif o == '-p' or o == '--glob-input': + glob_input = a elif o == '-f' or o == '--fragment-options': fragment_options = a elif o == '--template': @@ -90,18 +102,19 @@ for opt in options: else: raise Exception ('unknown option: ' + o) -texi_file_re = re.compile ('.*\.i?te(ly|xi)$') -html_file_re = re.compile ('.*\.i?htm(l)?$') -xml_file_re = re.compile ('.*\.i?(xm|mx)l$') -tex_file_re = re.compile ('.*\.i?(la)?tex$') +html_file_re = re.compile ('.*\.i?html?$') +info_file_re = re.compile ('.*\.info$') pdf_file_re = re.compile ('.*\.i?pdf$') +tex_file_re = re.compile ('.*\.i?(la)?tex$') +texi_file_re = re.compile ('.*\.i?te(ly|xi|xinfo)$') +xml_file_re = re.compile ('.*\.i?(xm|mx)l$') def name2line (n): if texi_file_re.match (n): # We have a texi include file, simply include it: s = r"@include %s" % os.path.basename (n) - elif (html_file_re.match (n) or pdf_file_re.match (n) or - tex_file_re.match (n)): + elif (html_file_re.match (n) or info_file_re.match (n) + or pdf_file_re.match (n) or tex_file_re.match (n)): s = r""" @ifhtml @html @@ -136,6 +149,11 @@ def name2line (n): """ % (os.path.basename (n), fragment_options, n) return s +if glob_input: + files = glob.glob(glob_input) +elif input_filename: + files = open(input_filename).read().split() + if files: dir = os.path.dirname (name) or "." # don't strip .tely extension, Documentation/snippets uses .itely