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

Function maybe_pyc_file

crates/vm/src/vm/python_run.rs:150–155  ·  view source on GitHub ↗

Check whether a file is maybe a pyc file. Detection is performed by: 1. Checking if the filename ends with ".pyc" 2. If not, reading the first 2 bytes and comparing with the magic number

(path: &str)

Source from the content-addressed store, hash-verified

148 /// 1. Checking if the filename ends with ".pyc"
149 /// 2. If not, reading the first 2 bytes and comparing with the magic number
150 fn maybe_pyc_file(path: &str) -> bool {
151 if path.ends_with(".pyc") {
152 return true;
153 }
154 maybe_pyc_file_with_magic(path).unwrap_or(false)
155 }
156
157 fn maybe_pyc_file_with_magic(path: &str) -> std::io::Result<bool> {
158 let path_obj = std::path::Path::new(path);

Callers 1

run_simple_file_innerMethod · 0.85

Calls 2

ends_withMethod · 0.80

Tested by

no test coverage detected