Commit 0fbf8efa authored by Minkush Jain's avatar Minkush Jain

Update source_scanner.py with variable names

parent 6eb2e1a3
......@@ -4,57 +4,67 @@ import pygount
import file_extensions
from file_extensions import *
a = []
x=[]
file_path = []
code_line = []
path = input("Enter the script's directory's path: ")
analyse_location ="C:\\Users\\Minkush\\Desktop"
for (dirpath, dirnames, filenames) in walk(path):
for f in filenames:
location = os.path.join(dirpath, f)
a.append(location)
for (dirpath, dirnames, filenames) in walk(analyse_location):
for files in filenames:
location = os.path.join(dirpath, files)
file_path.append(location)
total_lines=0
for file_type in file_extensions.keys():
total=0
for i in file_extensions.keys():
sum=0
for j in range(len(a)):
if isinstance(file_extensions[i],list)==True:
for k in file_extensions[i]:
if k in str(a[j]):
analysis = pygount.source_analysis(a[j], 'pygount')
for path in range(len(file_path)):
if isinstance(file_extensions[file_type],list)==True:
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
elif file_extensions[i] in str(a[j]):
analysis = pygount.source_analysis(a[j], 'pygount')
elif file_extensions[file_type] in str(file_path[path]):
analysis = pygount.source_analysis(file_path[path], 'pygount')
sum = sum + analysis.code
total = total + sum
x.append(sum)
total_lines = total_lines + sum
code_line.append(sum)
if sum!=0:
print("%s: %s line(s) of code" %(i, sum))
if sum!=0:
print("%s: %s line(s) of code" %(file_type, sum))
print("\n")
randomlist=[]
file_types=[]
for languages in file_extensions.keys():
for i in file_extensions.keys():
file_types.append(languages)
randomlist.append(i)
language_percent = {}
abc = {}
# i is a variable for loop
for i in range(len(code_line)):
for i in range(len(x)):
percentage=(code_line[i]/total_lines)*100
language_percent[file_types[i]] = percentage
b=(x[i]/total)*100
abc[randomlist[i]] = b
if percentage!=0:
if b!=0:
print("Percentage of %s : %.3f %s " %(randomlist[i], b, "%"))
print("Percentage of %s : %.3f %s " %(file_types[i], percentage, "%"))
popular = max(abc, key=abc.get)
print("\nYou are most proficient in %s language" %(popular))
popular_lang = max(language_percent, key=language_percent.get)
print("\nYou are most proficient in %s language" %(popular_lang))
\ No newline at end of file
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