# it is not, for --srcdir builds
$(outdir)/%.texi: %.tely
if [ -f $@ ]; then chmod a+w $@; fi
- $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) $<
+ time $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) $<
chmod -w $@
$(outdir)/%.texi: $(outdir)/%.tely
# for plain info doco: don't run lily
$(outdir)/%.nexi: %.tely
if [ -f $@ ]; then chmod a+w $@; fi
- $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) --process='true' $<
+ time $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) --process='true' $<
mv $(outdir)/$*.texinfo $@ 2>/dev/null || mv $(outdir)/$*.texi $@
chmod -w $@
pass # todo
+def find_toplevel_snippets (infile, outfile, types):
+ s = infile.read ()
+ res = {}
+ for i in types:
+ res[i] = ly.re.compile (snippet_res[format][i])
+
+ snippets = []
+ index = 0
+ found = dict ([(t, None) for t in types] )
+
+ #
+ # We want to search for multiple regexes,
+ # without searching the string multiple times for one regex.
+ #
+ # Hence, we use earlier results to limit the string portion
+ # where we search. We're hosed if the first type only occurs
+ # at the end of the string, since it will then use quadratic
+ # time.
+ #
+
+ while 1:
+ first = None
+ endex = 1 << 30
+ for type in types:
+ if not found[type] or found[type].start (0) < index:
+ found[type] = None
+ m = res[type].search (s[index:endex])
+ if m:
+ found[type] = Snippet (type, m)
+
+ if found[type] \
+ and (first == None \
+ or found[type].start (0) < found[first].start (0)):
+
+ first = type
+ endex = found[first].start (0)
+
+ if not first:
+ break
+
+ snippets.append (found[first])
-def simple_find_toplevel_snippets (str, types):
- "return: (new string, snippets)"
- snippets = []
- for t in types:
- regex = re.compile (snippet_res[format][t])
+ outfile.write (s[index:index + found[first].start (0)])
+ outfile.write (found[first].replacement_text ())
+
+ index += found[first].end (0)
- # ugh, this can be done nicer in python 2.x
- def notice_snippet (match, snippets = snippets,
- t = t, str = str):
- s = Snippet (t, str, match)
- snippets.append (s)
+ return snippets
-
- return s.replacement_text (format)
- str = regex.sub (notice_snippet, str)
- return (str, snippets)
-def find_toplevel_snippets (infile, outfile, types):
- res = ['(?P<regex%s>%s)' % (t,
-
- re.sub (r"\(\?P<[^>]+>", "(", snippet_res[format][t]))
- for t in types]
-
- big_re = re.compile (string.join (res, '|'))
- str = infile.read ()
- i = big_re.finditer(str)
-
- snips= []
- last_end = 0
- for match in i:
- outfile.write (str[last_end:match.start (0)])
- last_end = match.end (0)
- for t in types:
- m =re.match (snippet_res[format][t], match.group(0))
- if m:
- sn = Snippet (t, m)
- snips.append (sn)
- outfile.write (sn.replacement_text (format))
- break
- return snips
def filter_pipe (input, cmd):
ly.progress ('\n')
ly.progress (_ ("Dissecting..."))
- #snippets = find_toplevel_snippets (source, snippet_res[format].keys ())
snippet_types = (
'lilypond_block',
'verb',