diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-12-25 23:36:35 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-12-25 23:36:39 -0800 |
commit | 4bdf3106e13576e1b46a1d5e2e841ebc61045ee1 (patch) | |
tree | 8796266af0f1555feafad5720ede6a83dbfd54a5 /src | |
parent | 3e3f933595f64083e41433075e66aa275af66c6c (diff) | |
download | modelthing-4bdf3106e13576e1b46a1d5e2e841ebc61045ee1.tar.gz modelthing-4bdf3106e13576e1b46a1d5e2e841ebc61045ee1.zip |
remove variables from metadata files
Plan here is to make these examples only.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 26 |
1 files changed, 0 insertions, 26 deletions
@@ -18,7 +18,6 @@ use std::fs::File; pub struct ModelMetadata { pub name_en: String, pub description_en: Option<String>, - pub vars: Vec<ModelVar>, } #[derive(Debug, PartialEq)] @@ -53,34 +52,9 @@ pub fn parse_metadata(raw: String) -> Result<ModelMetadata, String> { .expect("missing 'model' section") .as_table() .unwrap(); - let variables = root.get("variables") - .expect("missing 'variables' section") - .as_table() - .unwrap(); - let mut vars = vec![]; - for (slug, info) in variables { - let info = info.as_table().unwrap(); - let vtype = match info.get("type").unwrap().as_str().unwrap() { - "independent" => ModelVarType::Independent, - "dependent" => ModelVarType::Dependent, - "constant" => ModelVarType::Constant, - "time" => ModelVarType::Time, - "state" => ModelVarType::State, - "parameter" => ModelVarType::Parameter, - other => return Err(format!("Unknown variable type: {}", other)), - }; - vars.push(ModelVar { - slug: slug.to_string(), - name_en: info.get("name-en").map(|x| x.as_str().unwrap().to_string()), - vtype: vtype, - latex: info.get("latex").map(|x| x.as_str().unwrap().to_string()), - units_si: info.get("units-si").map(|x| x.as_str().unwrap().to_string()), - }); - } Ok(ModelMetadata { name_en: model.get("name-en").unwrap().as_str().unwrap().to_string(), description_en: model.get("description-en").map(|x| x.as_str().unwrap().to_string()), - vars: vars, }) } |