From 4fbb5fbb255761c006b876b26c24c9e1dbee7a51 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Tue, 10 Sep 2019 15:48:08 +0000 Subject: [PATCH] Make it easier to run src/top_evil_rs.py from git root Currently, `src/top_evil_rs.py' script recursively scans current directory for Rust sources and print statistics about them. When run from git root, it also scans target/ directory, which is useless. This commit add cludge that checks if script is run from git root directory, and `chdir' into `src/' before performing actions. Unprincipled, but convenient. --- src/top_evil_rs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/top_evil_rs.py b/src/top_evil_rs.py index a64c3f4b7..278d7f354 100755 --- a/src/top_evil_rs.py +++ b/src/top_evil_rs.py @@ -6,6 +6,8 @@ import os import re if __name__ == "__main__": + if Path('src/top_evil_rs.py').exists(): + os.chdir('src') filestats = [] for fn in Path(".").glob("**/*.rs"): s = fn.read_text()