init
This commit is contained in:
20
DungeonSolver.Workspace/statistic.py
Normal file
20
DungeonSolver.Workspace/statistic.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
|
||||
def count_cs_lines(root_dir: str):
|
||||
total = 0
|
||||
for dirpath, _, filenames in os.walk(root_dir):
|
||||
for filename in filenames:
|
||||
if filename.endswith(".cs"):
|
||||
filepath = os.path.join(dirpath, filename)
|
||||
with open(filepath, "r", encoding="utf-8", errors="ignore") as f:
|
||||
lines = [
|
||||
line for line in f
|
||||
if line.strip() and not line.strip().startswith("//")
|
||||
]
|
||||
total += len(lines)
|
||||
print(f"Total non-empty lines in .cs files: {total}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
count_cs_lines(".")
|
||||
|
||||
Reference in New Issue
Block a user