Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import glob
- excepts = {
- 'files': {
- 'exts': ['.sqlite3', '.png', '.jpeg', '.pyc'],
- },
- 'dirs': [
- '.git',
- 'node_modules',
- '__pycache__'
- ]
- }
- lines = {ext: {} for ext in ['py', 'html']}
- # glob.glob()
- def main():
- print('-'* 50)
- print('')
- root_dir = os.path.abspath(os.curdir) if len(sys.argv) > 0 else sys.argv[1]
- print('starts scan: ' + root_dir + '\n')
- def get_lines_in_files(files, _dir = ''):
- for file in files:
- with open(file, 'r') as eyes:
- # print(file)
- ext = file.split('.').pop()
- if ext in lines.keys():
- lines[ext][(file + (f'__{_dir}') if _dir else file)] = len(eyes.readlines())
- # root_dirs = os.listdir(root_dir)
- def get_lines_in_folder(path_name):
- for root, dirs, files in os.walk(root_dir):
- get_lines_in_files(files)
- get_lines_in_folder(root_dir)
- for _ext, _files in lines.items():
- _sum = sum(_files.values())
- print(_ext.upper() + f': (total {_sum} lines)\n')
- for _file, count in _files.items():
- print(f"{_file}: {count}")
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement