From 54c2cb1e484e09b4fcfe236aff70c01bf3bbaae0 Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 9 Oct 2016 08:40:07 +0200 Subject: serien hinzugefuegt, aber ich muss auf die naechste rust nightly warten diff --git a/Cargo.lock b/Cargo.lock index 8cc593d..3efbb7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,11 +3,10 @@ name = "acd_character_parser" version = "0.1.0" dependencies = [ "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "yaml-rust 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -57,7 +56,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -79,33 +78,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_codegen" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen_internals 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen_internals 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_codegen_internals" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "syn 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_codegen 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -116,15 +115,15 @@ dependencies = [ "dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -174,33 +173,3 @@ name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "yaml-rust" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" -"checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d" -"checksum itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3088ea4baeceb0284ee9eea42f591226e6beaecf65373e41b38d95a1b8e7a1" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "408014cace30ee0f767b1c4517980646a573ec61a57957aeeabcac8ac0a02e8d" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"checksum num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a16a42856a256b39c6d3484f097f6713e14feacd9bfb02290917904fae46c81c" -"checksum quote 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "502983ae4337dd7e30130ea1405d4bfc90424d8a38133baa68340b86f340dbfb" -"checksum regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)" = "64b03446c466d35b42f2a8b203c8e03ed8b91c0f17b56e1f84f7210a257aa665" -"checksum regex-syntax 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279401017ae31cf4e15344aa3f085d0e2e5c1e70067289ef906906fdbe92c8fd" -"checksum serde 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)" = "7a1687e7258b35aa6117cb52d65aa8f289d544fdad0c7a31822973b4465e4066" -"checksum serde_codegen 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)" = "44d2c5df2af5b1e603d911d3c4f30febc2f0f25426ef9f468ba256c965f5afe8" -"checksum serde_codegen_internals 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fb3bda24f9eee7446793d209f7edac5400f85f002bff1c3d59ec678c728c9e" -"checksum serde_derive 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)" = "658f0eea61a92a8574de65f05b84e210e08d5de5943fdc9a3d87ac17553803b9" -"checksum serde_json 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b3bb42fa42265df8a1822b3db2090bc8f9e17e8142599c76a5b854bc4e7b5b" -"checksum syn 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "666432ba8bf7a7bd46ec84b7c71739cc4836b5357aa3b76e0ea6da15f01f6220" -"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" -"checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" -"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -"checksum walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c66c0b9792f0a765345452775f3adbd28dde9d33f30d13e5dcc5ae17cf6f3780" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum yaml-rust 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ebfe12f475ad59be6178ebf004d51e682022496535994f8d23fd7ed31084598c" diff --git a/Cargo.toml b/Cargo.toml index 8d5f0b9..34e4f6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ authors = ["jan "] [dependencies] regex = "0.1" walkdir = "0.1" -yaml-rust = "0.3" serde = "0.8" serde_derive = "0.8" diff --git a/config.yml b/config.yml deleted file mode 100644 index 313d8e2..0000000 --- a/config.yml +++ /dev/null @@ -1,25 +0,0 @@ -sections: - name: - pattern: (?is)Romaji Name.*?(.*?)\s?.*?Japanese Name.*?(.*?)\s?.*?Aliases.*?(.*?)\s? - groups: - - romaji - - japanese - - aliases - misc: - pattern: (?is)Role.*?(.*?)\s? - groups: - - role - image: - pattern: (?is)

.*.*?

View Full Size Image - groups: - - thumb - - full - tags: - pattern: (?is)tagged as

.*?(.*?) - groups: - - tags_raw - traits: - pattern: (?is)indexed traits

.*?
(.*?)
.*?official traits\s?

.*?
(.*?)
- groups: - - indexed_raw - - official_raw diff --git a/src/main.rs b/src/main.rs index 2b96024..7481376 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate serde_derive; extern crate serde_json; @@ -22,6 +22,8 @@ mod section; mod character; use character::Character; +mod series; +use series::Series; mod tags; mod dl_list; @@ -66,7 +68,7 @@ fn main() { let buf = pre_process::strip_irrelevant_content(&buf); - let mut char = Character::new(); + let mut char = Series::new(); char.parse(&buf); let json = serde_json::to_string(&char).unwrap(); diff --git a/src/series.rs b/src/series.rs new file mode 100644 index 0000000..d111fb8 --- /dev/null +++ b/src/series.rs @@ -0,0 +1,63 @@ +use super::tags; +use super::tags::Tag; +use super::dl_list; +use super::dl_list::DLListItem; +use super::section; +use super::section::Section; +use super::regex::Regex; +use super::tiles; + +use std::collections::HashMap; + +#[derive(Debug, Serialize)] +pub struct Names { + pub english: String, + pub aliases: String, + pub romaji: String, + pub furigana: String, + pub japanese: String, +} + +#[derive(Debug, Serialize)] +pub struct Series { + pub name: Names, +} + +impl Names { + pub fn new() -> Self { + Names { + String::new(), String::new(), String::new(), String::new(), String::new() + } + } +} + +impl Series { + pub fn new() -> Self { + Series { + name: Names::new() + } + } + + pub fn parse(&mut self, buf: &str) { + let mut sections = get_sections(); + section::process(&buf, &mut sections); + + { + let name: &Section = §ions["name".into()]; + + self.name.english = name["english".into()]; + self.name.aliases = name["aliases".into()]; + self.name.romaji = name["romaji".into()]; + self.name.furigana = name["furigana".into()]; + self.name.japanese = name["japanese".into()]; + } + } +} + +fn get_sections() -> HashMap { + let mut s: HashMap = HashMap::new(); + + s.insert("name".into(), Section::new("name", r#"(?is)English Title.*?(.*?).*?Aliases.*?(.*?)?.*?Romaji Title.*?(.*?).*?Furigana Title.*?(.*?).*?Japanese Title.*?(.*?)"#, vec!["english", "aliases", "romaji", "furigana", "japanese"])); + + s +} -- cgit v0.10.1