On 01/07/13 at 05:24pm, Glen Larsen wrote: > Very cool, David. > Felix, I knew you'd want something like this made out of that: > Simple python wrapper for this scheme code <https://gist.github.com/4480245>
Yeah, I think it still needs some processing. IMO, The header fields should be checked for their validity and the remaining fields written to a preliminary (incomplete) .rdf-file. (They are only required for the .rdf aren't they?) Your wrapper looks like a good start. >From reading David's mail I realised that header fields can also contain >newlines, which could mess up parsing. I'd replace those with nulls in the scheme and change them back with the python. (If there are nulls in header fields this will go wrong, but I don't really see an application for having nulls in header fields.) So varying David's command line a bit lilypond -e '(set! print-book-with-defaults (lambda (parser book) (module-for-each (lambda (sym var) (if (markup? (variable-ref var)) (format #t "~a=~a~%" sym (string-map (lambda (c) (if (eq? c #\newline) #\nul c)) (markup->string (variable-ref var)))))) (ly:book-header book))))' file.ly replaces newlines by nulls and prints header fields literally without escaping characters. (Otherwise the nulls would be displayed as "\x00".) Python's xml.sax.saxutils.escape looks useful for producing the .rdf format. Felix PS: Is supporting multiple files really necessary for the script? If there is a multiple file piece the relevant fields should be equal for any of the files (which are not only for inclusion in other files). Ok, one could compare the output for the different files and check whether that's really true; this doesn't seem to be worth the time, though. Raising this issue is probably also not worth the time, since it doesn't seem to make the script much more complicated and doesn't do any harm at all... _______________________________________________ Mutopia-discuss mailing list Mutopia-discuss@mutopiaproject.org http://lists.bcn.mythic-beasts.com/mailman/listinfo/mutopia-discuss