INNER CODE UNIT · Python

count_code_lines

AsPJT/PAX_SAPIENTICA · Scripts/CodeCounter.py:13

def count_code_lines(filename):
    with open(filename, 'r') as file:
        lines = file.readlines()

    code_line_count = 0
    multi_line_comment = False
    for line in lines:
        line = line.strip()
        if line.startswith('/*'):
            multi_line_comment = True

        if not multi_line_comment and not line.startswith('//') and line != '':
            code_line_count += 1

        if line.endswith('*/'):
            multi_line_comment = False

    return code_line_count

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…