-
- ly.progress (_ ("Reading %s...") % input_fullname)
- source = in_handle.read ()
- ly.progress ('\n')
-
- # FIXME: containing blocks must be first, see find_toplevel_snippets
- snippet_types = (
- 'multiline_comment',
- 'verbatim',
- 'lilypond_block',
-# 'verb',
- 'singleline_comment',
- 'lilypond_file',
- 'include',
- 'lilypond', )
- ly.progress (_ ("Dissecting..."))
- chunks = find_toplevel_snippets (source, snippet_types)
- ly.progress ('\n')
-
- global default_ly_options
- textwidth = 0
- if LINEWIDTH not in default_ly_options.keys ():
- if format == LATEX:
- textwidth = get_latex_textwidth (source)
- default_ly_options[LINEWIDTH] = '''%.0f\\pt''' \
- % textwidth
- elif format == TEXINFO:
- for (k, v) in texinfo_linewidths.items ():
- # FIXME: @paper is usually not in chunk #0:
- # \input texinfo @c -*-texinfo-*-
- # bluntly search first K of source
- # s = chunks[0].replacement_text ()
- if re.search (k, source[:1024]):
- default_ly_options[LINEWIDTH] = v
- break
-
- if filter_cmd:
- output_file.writelines ([c.filter_text () for c in chunks])
-
-
- elif process_cmd:
- outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
- and x.is_outdated (), chunks)
- ly.progress (_ ("Writing snippets..."))
- map (Lilypond_snippet.write_ly, outdated)
- ly.progress ('\n')
-
- if outdated:
- ly.progress (_ ("Processing..."))
- process_snippets (process_cmd, outdated)
- else:
- ly.progress (_ ("All snippets are up to date..."))