Skip to content

Instantly share code, notes, and snippets.

@ichisadashioko
Created November 14, 2019 05:12
Show Gist options
  • Save ichisadashioko/e757f8f8a7959bb197ee74d64fdf9e01 to your computer and use it in GitHub Desktop.
Save ichisadashioko/e757f8f8a7959bb197ee74d64fdf9e01 to your computer and use it in GitHub Desktop.
import os
import re
def count_code_lines(fpath):
count = 0
if os.path.isdir(fpath):
file_list = os.listdir(fpath)
for fname in file_list:
child_path = os.path.join(fpath, fname)
count += count_code_lines(child_path)
else:
ext = os.path.splitext(fpath)[1]
if ext == '.java':
count += len(open(fpath, mode='r', encoding='utf-8').readlines())
return count
if __name__ == "__main__":
fpath = r'E:\Programs\jd-gui-windows-1.6.4\heroes-lore-wind-of-solti.jar.src'
print(repr(fpath))
print(count_code_lines(fpath))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment