11# -*- coding: utf-8 -*-
22# Created on : 2025-08-09
33# @author : mefamex
4- # FOR : mefamex.com website depth file
4+ # FOR : folder depth file
55
66print (
77 "\n " ,
2727 + "#" * 82 + "\n \n "
2828)
2929
30- import os ,time , datetime
30+ __version__ = '1.0.3'
31+ __last_modified__ = '2025-08-13'
3132
32- text = '# Created for : mefamex.com files\n # Created on : ' + datetime .datetime .now ().isoformat (timespec = 'seconds' ) + 'Z\n '
33+ import os ,time , datetime
34+ from pathlib import Path
35+ text = f'# Created for : { Path (__file__ ).parent .name } \n # Created on : ' + datetime .datetime .now ().isoformat (timespec = 'seconds' ) + 'Z\n '
3336
37+ # Hedef Uzantılar
38+ TARGET_EXTENSIONS = {'.txt' , 'bat' , '.md' , '.py' , '.html' , 'css' , '.js' , 'json' }
39+ # starts with or ends with
40+ IGNORED_FOLDERS = {'.git' , '__pycache__' , '.venv' , 'venv' }
3441
3542def count_characters_in_file (file_path ):
3643 try :
@@ -51,8 +58,8 @@ def create_table(results, grand_total_char, grand_total_files):
5158
5259 for ext in sorted_exts :
5360 file_count , char_count = len (results [ext ]['files' ]), results [ext ]['total_chars' ]
61+ if file_count == 0 and char_count == 0 : continue
5462 table_data .append ({ 'type' : ext [1 :].upper (), 'char' : f"{ char_count :,} " if char_count > 0 else "---" , 'file' : str (file_count ) if file_count > 0 else "---" })
55-
5663 # Sütun genişliklerini hesapla
5764 type_width = max (len ("TYPE" ), max (len (row ['type' ]) for row in table_data )) + 2
5865 char_width = max (len ("CHAR" ), max (len (row ['char' ]) for row in table_data )) + 2
@@ -66,23 +73,24 @@ def create_table(results, grand_total_char, grand_total_files):
6673 table += "|" + "-" * type_width + "|" + "-" * char_width + "|" + "-" * file_width + "|\n "
6774
6875 for row in table_data :
69- table += f"| { row ['type' ]:< {type_width - 1 }} | { row ['char' ]:<{char_width - 1 }} | { row ['file' ]:<{file_width - 1 }} |\n "
70-
71- table += f"{ separator } \n \n TOTAL CHARS : { grand_total_char :,} \n TOTAL FILES : { grand_total_files :,} \n \n in mefamex.com \n "
72-
76+ table += f"|{ row ['type' ]:> {type_width - 1 }} | { row ['char' ]:<{char_width - 1 }} | { row ['file' ]:<{file_width - 1 }} |\n "
77+
78+ table += f"{ separator } \n \n TOTAL CHARS : { grand_total_char :,} \n TOTAL FILES : { grand_total_files :,} \n \n " + f" in { Path ( __file__ ). parent . name } " . rjust ( 25 ) + " \n "
79+
7380 return table
7481
7582
7683
7784def analyze_directory (directory ):
7885 global text
79- target_extensions = { '.html' , '.txt' , '.md' , '.js' , '.css' , '.py' }
80- ignored_folders = { '.git' , '__pycache__' }
86+ target_extensions = TARGET_EXTENSIONS
87+ ignored_folders = IGNORED_FOLDERS
8188 grand_total_char , grand_total_files = 0 , 0
8289 results = {ext : {'files' : [], 'total_chars' : 0 } for ext in target_extensions }
8390
8491 for root , _ , files in os .walk (directory ):
85- if any (ignored in root for ignored in ignored_folders ): continue
92+ for q in ignored_folders :
93+ if Path (root ).name .startswith (q ) or Path (root ).name .endswith (q ):continue
8694 print ("reading folder:" , root )
8795 for file in files :
8896 _ , ext = os .path .splitext (file )
0 commit comments