HyperDbg Debugger
Loading...
Searching...
No Matches
counter Namespace Reference

Functions

 CountLines (start, lines=0, header=True, begin_start=None)
 

Function Documentation

◆ CountLines()

counter.CountLines ( start,
lines = 0,
header = True,
begin_start = None )
3def CountLines(start, lines=0, header=True, begin_start=None):
4 if header:
5 print('{:>10} |{:>10} | {:<20}'.format('ADDED', 'TOTAL', 'FILE'))
6 print('{:->11}|{:->11}|{:->20}'.format('', '', ''))
7
8 for thing in os.listdir(start):
9 thing = os.path.join(start, thing)
10 if os.path.isfile(thing):
11 if ('\\dependencies\\zydis' not in thing and '\\dependencies\\ia32-doc' not in thing) and (thing.endswith('.c') or thing.endswith('.h') or thing.endswith('.cpp') or thing.endswith('.asm') or thing.endswith('.py') or thing.endswith('.cs') or thing.endswith('.scala') or thing.endswith('.tcl') or thing.endswith('.scala') or thing.endswith('.sh') or thing.endswith('.config') or thing.endswith('.ds') or thing.endswith('.hex') or thing.endswith('.txt') or thing.endswith('.md') or thing.endswith('.bat')):
12
13 with open(thing, 'r', encoding="latin-1") as f:
14 newlines = f.readlines()
15 newlines = len(newlines)
16 lines += newlines
17
18 if begin_start is not None:
19 reldir_of_thing = '.' + thing.replace(begin_start, '')
20 else:
21 reldir_of_thing = '.' + thing.replace(start, '')
22
23 print('{:>10} |{:>10} | {:<20}'.format(
24 newlines, lines, reldir_of_thing))
25
26
27 for thing in os.listdir(start):
28 thing = os.path.join(start, thing)
29 if os.path.isdir(thing):
30 lines = CountLines(thing, lines, header=False, begin_start=start)
31
32 return lines
33