aboutsummaryrefslogtreecommitdiff
path: root/src/pre_process.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pre_process.rs')
-rw-r--r--src/pre_process.rs34
1 files changed, 0 insertions, 34 deletions
diff --git a/src/pre_process.rs b/src/pre_process.rs
index 273562d..877ddc3 100644
--- a/src/pre_process.rs
+++ b/src/pre_process.rs
@@ -1,7 +1,3 @@
1use super::regex::Regex;
2
3use std::collections::HashMap;
4
5pub fn strip_irrelevant_content(s: &str) -> String { 1pub fn strip_irrelevant_content(s: &str) -> String {
6 let mut retn = ""; 2 let mut retn = "";
7 match s.find(r#"<div class=profile id=profile>"#) { 3 match s.find(r#"<div class=profile id=profile>"#) {
@@ -16,34 +12,4 @@ pub fn strip_irrelevant_content(s: &str) -> String {
16 return retn.into(); 12 return retn.into();
17} 13}
18 14
19pub struct Section {
20 pub name: String,
21 pub re: Regex,
22 pub keys: Vec<String>,
23 pub data: HashMap<String, String>,
24}
25 15
26impl Section {
27 pub fn new(name: &str, re: &str, groups: Vec<String>) -> Self {
28 Section {
29 name: name.into(),
30 re: Regex::new(re).unwrap(),
31 keys: groups,
32 data: HashMap::new(),
33 }
34 }
35}
36
37pub fn split_sections(d: &str, s: &mut HashMap<String, Section>) {
38 for (_, section) in s {
39 for m in section.re.captures_iter(d) {
40 assert!(m.len() >= section.keys.len() + 1);
41
42 let mut idx = 0;
43 for key in &section.keys {
44 section.data.insert(key.clone(), m.at(idx + 1).unwrap().into());
45 idx += 1;
46 }
47 }
48 }
49}