-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add an example usecase of the parser. #1177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
examples/parse_folder.rs
Outdated
|
||
fn main() { | ||
env_logger::init(); | ||
let app = App::new("RustPython") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since RustPython
is the name of the whole project and, presumably, its interpreter as a stand-alone application – shouldn’t this be called something else (or at least – more specific)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, copy paste error, thanks!
examples/parse_folder.rs
Outdated
res.extend(x); | ||
} | ||
|
||
if metadata.is_file() && path.extension().map(|s| s.to_str().unwrap()) == Some("py") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if metadata.is_file() && path.extension().map(|s| s.to_str().unwrap()) == Some("py") { | |
if metadata.is_file() && path.extension().and_then(|s| s.to_str()) == Some("py") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
if folder.exists() && folder.is_dir() { | ||
println!("Parsing folder of python code: {:?}", folder); | ||
let res = parse_folder(&folder).unwrap(); | ||
println!("Processed {:?} files", res.len()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it print the parsed files or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some ideas for metrics:
- parsed lines per second
- print the amount of functions / classes
For now, I just use it to try and scan my cpython lib folder
No description provided.