Commit 6e56c212 authored by Minkush Jain's avatar Minkush Jain

add stand-alone script condition

parent 0fbf8efa
......@@ -4,67 +4,76 @@ import pygount
import file_extensions
from file_extensions import *
file_path = []
code_line = []
analyse_location ="C:\\Users\\Minkush\\Desktop"
def source_code_scanner(analyse_location):
for (dirpath, dirnames, filenames) in walk(analyse_location):
file_path = []
code_line = []
for files in filenames:
location = os.path.join(dirpath, files)
file_path.append(location)
for (dirpath, dirnames, filenames) in walk(analyse_location):
for files in filenames:
total_lines=0
location = os.path.join(dirpath, files)
file_path.append(location)
for file_type in file_extensions.keys():
sum=0
for path in range(len(file_path)):
total_lines=0
if isinstance(file_extensions[file_type],list)==True:
for file_type in file_extensions.keys():
for extension in file_extensions[file_type]:
sum=0
for path in range(len(file_path)):
if extension in str(file_path[path]):
if isinstance(file_extensions[file_type],list)==True:
analysis = pygount.source_analysis(file_path[path], 'pygount')
sum = sum + analysis.code
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[file_type] in str(file_path[path]):
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 = sum + analysis.code
total_lines = total_lines + sum
code_line.append(sum)
total_lines = total_lines + sum
code_line.append(sum)
if sum!=0:
if sum!=0:
print("%s: %s line(s) of code" %(file_type, sum))
print("%s: %s line(s) of code" %(file_type, sum))
print("\n")
file_types=[]
print("\n")
file_types=[]
for languages in file_extensions.keys():
file_types.append(languages)
language_percent = {}
for languages in file_extensions.keys():
# i is a variable for loop
for i in range(len(code_line)):
file_types.append(languages)
percentage=(code_line[i]/total_lines)*100
language_percent[file_types[i]] = percentage
language_percent = {}
if percentage!=0:
# i is a variable for loop
for i in range(len(code_line)):
print("Percentage of %s : %.3f %s " %(file_types[i], percentage, "%"))
percentage=(code_line[i]/total_lines)*100
language_percent[file_types[i]] = percentage
popular_lang = max(language_percent, key=language_percent.get)
print("\nYou are most proficient in %s language \n" %(popular_lang))
if percentage!=0:
print("Percentage of %s : %.3f %s " %(file_types[i], percentage, "%"))
if __name__ == "__main__":
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
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