diff options
author | jan <jan@ruken.pw> | 2016-09-30 23:16:19 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2016-09-30 23:16:19 (UTC) |
commit | a6b37fa5e1bd505adfae4888896be2a3aa49ec3a (patch) | |
tree | 0a381e0533489a78758b1516680e274f5fd82216 /src/main.rs | |
parent | 361ea3a80a60bc6595a7a624b6cc5d71ddc8f6fc (diff) |
parsen von traits und tags, wir koennen den configkram eigentlich wieder komplett entfernen. klappt so nicht wirklich.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 7d06fe7..ee8c3eb 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -16,15 +16,21 @@ use pre_process::Section; | |||
16 | mod config; | 16 | mod config; |
17 | use config::Config; | 17 | use config::Config; |
18 | 18 | ||
19 | mod character; | ||
20 | use character::{Images, Names, Traits, Character}; | ||
21 | |||
22 | mod tags; | ||
23 | mod traits; | ||
24 | |||
19 | fn main() { | 25 | fn main() { |
20 | let raw_files = env::var("RAW_FILES").unwrap_or("characters".into()); | 26 | let raw_files = env::var("RAW_FILES").unwrap_or("characters".into()); |
21 | let base_path = Path::new(&raw_files); | 27 | let base_path = Path::new(&raw_files); |
22 | 28 | ||
23 | let cfg = Config::from_file("config.yml"); | 29 | let cfg = Config::from_file("config.yml", vec!["name", "image", "misc", "tags", "traits"]); |
24 | 30 | ||
25 | let mut sections: Vec<Section> = vec![]; | 31 | let mut sections: HashMap<String, Section> = HashMap::new(); |
26 | for (name, sec) in &cfg.sections { | 32 | for (name, sec) in &cfg.sections { |
27 | sections.push(Section::new(&name, &sec.pattern, sec.groups.clone())); | 33 | sections.insert(name.clone(), Section::new(&name, &sec.pattern, sec.groups.clone())); |
28 | } | 34 | } |
29 | 35 | ||
30 | for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) { | 36 | for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) { |
@@ -39,11 +45,30 @@ fn main() { | |||
39 | 45 | ||
40 | pre_process::split_sections(&buf, &mut sections); | 46 | pre_process::split_sections(&buf, &mut sections); |
41 | 47 | ||
42 | let mut char: HashMap<String, HashMap<String, String>> = HashMap::new(); | 48 | { |
43 | for s in §ions { | 49 | let name: &Section = §ions["name".into()]; |
44 | char.insert(s.name.clone(), s.data.clone()); | 50 | let image: &Section = §ions["image".into()]; |
51 | let misc: &Section = §ions["misc".into()]; | ||
52 | println!("{:?}", Character { | ||
53 | name: Names { | ||
54 | romaji: name.data["romaji".into()].clone(), | ||
55 | japanese: name.data["japanese".into()].clone(), | ||
56 | aliases: name.data["aliases".into()].split(", ").map(|s| s.to_string()).collect(), | ||
57 | }, | ||
58 | image: Images { | ||
59 | thumb: image.data["thumb".into()].clone(), | ||
60 | full: image.data["full".into()].clone(), | ||
61 | }, | ||
62 | tags: tags::parse(&(§ions["tags".into()] as &Section).data["tags_raw".into()]), | ||
63 | traits: Traits { | ||
64 | official: traits::parse(&(§ions["traits"] as &Section).data["official_raw".into()]), | ||
65 | indexed: traits::parse(&(§ions["traits"] as &Section).data["indexed_raw".into()]), | ||
66 | }, | ||
67 | role: match misc.data["role".into()].len() > 0 { | ||
68 | true => Some(misc.data["role".into()].clone()), | ||
69 | false => None | ||
70 | } | ||
71 | }); | ||
45 | } | 72 | } |
46 | |||
47 | println!("{:?}", char); | ||
48 | } | 73 | } |
49 | } | 74 | } |