SectionConfig::write - verify data
This commit is contained in:
parent
aeb4c8217b
commit
ae3a512dd9
@ -82,27 +82,31 @@ impl SectionConfig {
|
|||||||
|
|
||||||
let mut done = HashSet::new();
|
let mut done = HashSet::new();
|
||||||
|
|
||||||
for id in &config.order {
|
for section_id in &config.order {
|
||||||
if config.sections.get(id) == None { continue };
|
if config.sections.get(section_id) == None { continue };
|
||||||
list.push_back(id);
|
list.push_back(section_id);
|
||||||
done.insert(id);
|
done.insert(section_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (id, _) in &config.sections {
|
for (section_id, _) in &config.sections {
|
||||||
if done.contains(id) { continue };
|
if done.contains(section_id) { continue };
|
||||||
list.push_back(id);
|
list.push_back(section_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut raw = String::new();
|
let mut raw = String::new();
|
||||||
|
|
||||||
for id in list {
|
for section_id in list {
|
||||||
let (type_name, section_config) = config.sections.get(id).unwrap();
|
let (type_name, section_config) = config.sections.get(section_id).unwrap();
|
||||||
let plugin = self.plugins.get(type_name).unwrap();
|
let plugin = self.plugins.get(type_name).unwrap();
|
||||||
|
|
||||||
// fixme: verify json data
|
if let Err(err) = parse_simple_value(§ion_id, &self.id_schema) {
|
||||||
println!("REAL WRITE {} {} {:?}\n", id, type_name, section_config);
|
bail!("syntax error in section identifier: {}", err.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
let head = (self.format_section_header)(type_name, id, section_config);
|
verify_json_object(section_config, &plugin.properties)?;
|
||||||
|
println!("REAL WRITE {} {} {:?}\n", section_id, type_name, section_config);
|
||||||
|
|
||||||
|
let head = (self.format_section_header)(type_name, section_id, section_config);
|
||||||
|
|
||||||
if !raw.is_empty() { raw += "\n" }
|
if !raw.is_empty() { raw += "\n" }
|
||||||
|
|
||||||
@ -115,7 +119,7 @@ impl SectionConfig {
|
|||||||
Value::String(v) => v.to_string(),
|
Value::String(v) => v.to_string(),
|
||||||
Value::Number(v) => v.to_string(),
|
Value::Number(v) => v.to_string(),
|
||||||
_ => {
|
_ => {
|
||||||
bail!("file {}: got unsupported type in section {} key {}", filename, id, key);
|
bail!("got unsupported type in section '{}' key '{}'", section_id, key);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
raw += "\t";
|
raw += "\t";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user