(&self, path: Option<PathBuf>, use_short: bool)
| 2099 | } |
| 2100 | |
| 2101 | fn read_unicode(&self, path: Option<PathBuf>, use_short: bool) -> Result<()> { |
| 2102 | let path = match path { |
| 2103 | Some(p) => p, |
| 2104 | None => { |
| 2105 | // get the path to either the short or long unicode file |
| 2106 | let pref_manager = self.pref_manager.borrow(); |
| 2107 | let unicode_files = if self.name == RulesFor::Braille { |
| 2108 | pref_manager.get_braille_unicode_file() |
| 2109 | } else { |
| 2110 | pref_manager.get_speech_unicode_file() |
| 2111 | }; |
| 2112 | if use_short {unicode_files.0} else {unicode_files.1} |
| 2113 | } |
| 2114 | }; |
| 2115 | |
| 2116 | // FIX: should read first (lang), then supplement with second (region) |
| 2117 | // info!("Reading unicode file {}", path.to_str().unwrap()); |
| 2118 | let unicode_file_contents = read_to_string_shim(&path)?; |
| 2119 | let unicode_build_fn = |unicode_def_list: &Yaml| { |
| 2120 | let unicode_defs = unicode_def_list.as_vec(); |
| 2121 | if unicode_defs.is_none() { |
| 2122 | bail!("File '{}' does not begin with an array", yaml_to_type(unicode_def_list)); |
| 2123 | }; |
| 2124 | for unicode_def in unicode_defs.unwrap() { |
| 2125 | UnicodeDef::build(unicode_def, &path, self, use_short) |
| 2126 | .chain_err(|| {format!("In file {:?}", path.to_str())})?; |
| 2127 | }; |
| 2128 | return Ok(()); |
| 2129 | }; |
| 2130 | |
| 2131 | return compile_rule(&unicode_file_contents, unicode_build_fn) |
| 2132 | .chain_err(||format!("in file {:?}", path.to_str().unwrap())); |
| 2133 | } |
| 2134 | } |
| 2135 | |
| 2136 | use crate::prefs::FilesChanged; |
no test coverage detected