""" The purpose of this script is to count the number of lines of Python code in all Python scripts located below a given directory (passed as sys.argv[1]). You could use this script to compute the total number of lines of code you've written in this course, for example. However, there are a few pieces that need to be fixed before the script will work as intended. """ import os import sys import subprocess """ This is a convenience function for calling commands from the command line and returning their output as a list of strings. You do not need to modify this function. """ def easy_output( command ): return subprocess.check_output( command, encoding="utf-8" ).split( "\n" ) """ This function aims to use the system utility to count the number of lines in a file. Right now the function receives the raw output of but doesn't know what to do with it. Add code to extract the number of lines found in from and return that value as an INTEGER. """ def count_lines( path ): answer = 0 raw_output = easy_output( ["wc", "-l", path] ) # your code here return answer """ This function aims to find all of the Python scripts below a certain folder using the function and return them as a list of paths. Right now the function returns the paths of ALL files. Modify the trivial statement in the function so that only Python scripts will be included. """ def find_scripts( path ): """ find all Python scripts below a specified path """ scripts = [] for stem, folders, files in os.walk( path ): for name in files: if True: scripts.append( os.path.join( stem, name ) ) return scripts """ The block of code below will only execute when the script is run on the command line in script mode. This code is otherwise complete. """ if __name__ == "__main__": if len( sys.argv ) < 2: sys.exit( "usage: python .py " ) total = 0 for script in find_scripts( sys.argv[1] ): total += count_lines( script ) print( "I found", total, "lines of code below", sys.argv[1] )