MCPcopy Index your code
hub / github.com/RustPython/RustPython / parse_pyvenv_home

Function parse_pyvenv_home

crates/vm/src/getpath.rs:373–385  ·  view source on GitHub ↗

Parse pyvenv.cfg and extract the 'home' key value

(pyvenv_cfg: &Path)

Source from the content-addressed store, hash-verified

371
372/// Parse pyvenv.cfg and extract the 'home' key value
373fn 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)]
388mod tests {

Callers 1

detect_venvFunction · 0.85

Calls 5

okMethod · 0.80
to_lowercaseMethod · 0.80
trimMethod · 0.80
to_stringMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected