Commit 1ec17b79 authored by Minkush Jain's avatar Minkush Jain

fix pep-8 and variables

parent 2d9c8c02
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from os import *
import pygount
......@@ -7,11 +10,9 @@ from file_extensions import *
def source_code_scanner(analyse_location):
file_path = []
code_line = []
for (dirpath, dirnames, filenames) in walk(analyse_location):
for files in filenames:
......@@ -19,39 +20,38 @@ def source_code_scanner(analyse_location):
location = os.path.join(dirpath, files)
file_path.append(location)
total_lines=0
total_lines = 0
for file_type in file_extensions.keys():
sum=0
sum_of_lines = 0
for path in range(len(file_path)):
if isinstance(file_extensions[file_type],list)==True:
if isinstance(file_extensions[file_type], list) == True:
for extension in file_extensions[file_type]:
for extension in file_extensions[file_type]:
if extension in str(file_path[path]):
analysis = pygount.source_analysis(file_path[path], 'pygount')
sum = sum + analysis.code
if extension in str(file_path[path]):
analysis = \
pygount.source_analysis(file_path[path],
'pygount')
sum_of_lines += analysis.code
elif file_extensions[file_type] in str(file_path[path]):
analysis = pygount.source_analysis(file_path[path], 'pygount')
sum = sum + analysis.code
analysis = pygount.source_analysis(file_path[path],
'pygount')
sum_of_lines += analysis.code
total_lines = total_lines + sum_of_lines
code_line.append(sum_of_lines)
total_lines = total_lines + sum
code_line.append(sum)
if sum_of_lines != 0:
if sum!=0:
print ('%s: %s line(s) of code' % (file_type, sum_of_lines))
print("%s: %s line(s) of code" %(file_type, sum))
print("\n")
file_types=[]
print ('\n')
file_types = []
for languages in file_extensions.keys():
......@@ -60,20 +60,24 @@ def source_code_scanner(analyse_location):
language_percent = {}
# i is a variable for loop
for i in range(len(code_line)):
percentage=(code_line[i]/total_lines)*100
language_percent[file_types[i]] = percentage
percentage = code_line[i] / total_lines * 100
language_percent[file_types[i]] = percentage
if percentage!=0:
if percentage != 0:
print("Percentage of %s : %.3f %s " %(file_types[i], percentage, "%"))
print('Percentage of %s : %.3f %s ' % (file_types[i],
percentage, '%'))
popular_lang = max(language_percent, key=language_percent.get)
print("\nYou are most proficient in %s language \n" %(popular_lang))
print('''
You are most proficient in %s language
''' % popular_lang)
if __name__ == "__main__":
if __name__ == '__main__':
project_directory = input("Enter the script's directory's path: ")
source_code_scanner(project_directory)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment