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

Function read_home

crates/venvlauncher/src/main.rs:75–95  ·  view source on GitHub ↗

Parse the `home=` value from pyvenv.cfg

(cfg_path: &Path)

Source from the content-addressed store, hash-verified

73
74/// Parse the `home=` value from pyvenv.cfg
75fn read_home(cfg_path: &Path) -> Result<String, Box<dyn core::error::Error>> {
76 let content = fs::read_to_string(cfg_path)?;
77
78 for line in content.lines() {
79 let line = line.trim();
80 // Skip comments and empty lines
81 if line.is_empty() || line.starts_with('#') {
82 continue;
83 }
84
85 // Look for "home = <path>" or "home=<path>"
86 if let Some(rest) = line.strip_prefix("home") {
87 let rest = rest.trim_start();
88 if let Some(value) = rest.strip_prefix('=') {
89 return Ok(value.trim().to_string());
90 }
91 }
92 }
93
94 Err("'home' key not found in pyvenv.cfg".into())
95}
96
97/// Launch the Python process and wait for it to complete
98fn launch_process(exe: &Path, args: &[String]) -> Result<u32, Box<dyn core::error::Error>> {

Callers 4

runFunction · 0.85
test_read_homeFunction · 0.85
test_read_home_no_spacesFunction · 0.85

Calls 7

trimMethod · 0.80
starts_withMethod · 0.80
strip_prefixMethod · 0.80
trim_startMethod · 0.80
to_stringMethod · 0.80
ErrClass · 0.50
is_emptyMethod · 0.45

Tested by 3

test_read_homeFunction · 0.68
test_read_home_no_spacesFunction · 0.68