Skip to main content

settings_xml

Function settings_xml 

Source
pub fn settings_xml(settings: &[(String, Value)], indented: bool) -> String
Expand description

The settings as music21 writes them out, sorted by name: a <settings> element holding a <preference> for each value and an element apiece for the local corpora.

Compact, as ElementTree writes a tree it has not indented; with indented, as music21 writes .music21rc: two spaces a level and a closing newline, and no XML declaration, which ElementTree leaves out of a UTF-8 file.

use music21::environment::{settings_xml, Value};

let settings = [("debug".to_owned(), Value::Number(0)), ("braillePath".to_owned(), Value::Unset)];
assert_eq!(
    settings_xml(&settings, false),
    "<settings encoding=\"utf-8\"><preference name=\"braillePath\" />\
     <preference name=\"debug\" value=\"0\" /></settings>"
);