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

Function parse_folder

examples/parse_folder.rs:42–66  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

40}
41
42fn parse_folder(path: &Path) -> std::io::Result<Vec<ParsedFile>> {
43 let mut res = vec![];
44 info!("Parsing folder of python code: {path:?}");
45 for entry in path.read_dir()? {
46 debug!("Entry: {entry:?}");
47 let entry = entry?;
48 let metadata = entry.metadata()?;
49
50 let path = entry.path();
51 if metadata.is_dir() {
52 res.extend(parse_folder(&path)?);
53 }
54
55 if metadata.is_file() && path.extension().and_then(|s| s.to_str()) == Some("py") {
56 let parsed_file = parse_python_file(&path);
57 match &parsed_file.result {
58 Ok(_) => {}
59 Err(y) => error!("Error in file {path:?} {y:?}"),
60 }
61
62 res.push(parsed_file);
63 }
64 }
65 Ok(res)
66}
67
68fn parse_python_file(filename: &Path) -> ParsedFile {
69 info!("Parsing file {filename:?}");

Callers 1

mainFunction · 0.85

Calls 9

parse_python_fileFunction · 0.85
metadataMethod · 0.80
to_strMethod · 0.80
SomeClass · 0.50
pathMethod · 0.45
is_dirMethod · 0.45
extendMethod · 0.45
is_fileMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected