From 4ff469246f420c5a91d2a25eab9c21421abd3de9 Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 29 Sep 2016 13:23:10 +0200 Subject: parsen in eine grosse HashMap, jetzt auch mit namen (bisher ohne alias) diff --git a/src/main.rs b/src/main.rs index 2123c6b..97b3094 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ extern crate regex; -use regex::Regex; extern crate walkdir; use walkdir::WalkDir; @@ -7,7 +6,8 @@ use walkdir::WalkDir; use std::io::prelude::*; use std::fs::File; use std::env; -use std::path::{Path, PathBuf}; +use std::path::Path; +use std::collections::HashMap; mod pre_process; use pre_process::Section; @@ -17,12 +17,13 @@ fn main() { let base_path = Path::new(&raw_files); let mut sections: Vec
= vec![]; + sections.push(Section::new("name", r#"(?is)Romaji Name.*?(.*?)\s?.*?Japanese Name.*?(.*?)\s?"#, vec!["romaji".into(), "japanese".into()])); sections.push(Section::new("image", r#"(?is)

.*.*?

View Full Size Image"#, vec!["thumb".into(), "full".into()])); for entry in WalkDir::new(base_path).min_depth(1).into_iter().filter_map(|e| e.ok()) { let mut f = File::open(entry.path()).expect("could not open file"); let mut buf = String::new(); - if let Err(e) = f.read_to_string(&mut buf) { + if let Err(_) = f.read_to_string(&mut buf) { println!("invalid file: {}", entry.path().to_str().unwrap()); continue; } @@ -31,6 +32,11 @@ fn main() { pre_process::split_sections(&buf, &mut sections); - println!("{:?}", sections[0].data); + let mut char: HashMap> = HashMap::new(); + for s in §ions { + char.insert(s.name.clone(), s.data.clone()); + } + + println!("{:?}", char); } } -- cgit v0.10.1