Parse pyvenv.cfg and extract the 'home' key value
(pyvenv_cfg: &Path)
| 371 | |
| 372 | /// Parse pyvenv.cfg and extract the 'home' key value |
| 373 | fn parse_pyvenv_home(pyvenv_cfg: &Path) -> Option<String> { |
| 374 | let content = std::fs::read_to_string(pyvenv_cfg).ok()?; |
| 375 | |
| 376 | for line in content.lines() { |
| 377 | if let Some((key, value)) = line.split_once('=') |
| 378 | && key.trim().to_lowercase() == "home" |
| 379 | { |
| 380 | return Some(value.trim().to_string()); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | None |
| 385 | } |
| 386 | |
| 387 | #[cfg(test)] |
| 388 | mod tests { |
no test coverage detected