Question: Module that validates the flight school's records. This is the primary module that does all of the work. It loads the files,
Module that validates the flight school's records.
This is the primary module that does all of the work. It loads the files, loops through
the lessons, and searches for any takeoffs that violate insurance requirements.
Technically, we could have put many of these functions in mainpy That is the
main module of this application anyway. However, for testing purposes we want all
functions in modules and we only want script code in the file mainpy
Author: YOUR NAME HERE
Date: THE DATE HERE
import utils
import tests
import ospath
import violations
# Uncomment for the extra credit
#import endorsements
#import inspections
def discoverviolationsdirectoryoutput:
Searches the dataset directory for any flight lessons the violation regulations.
This function will call listweatherviolations to get the list of weather violations.
If listendorsmentviolations optional is completed, it will call that too, as
well as listinspectionviolations. It will concatenate all of these d lists
into a single d list of violations so a flight may be listed more than once for
each of the three types of violations
If the parameter output is not None, it will create the CSV file with name output
and write the d list of violations to this file. This CSV file should have the
following header:
STUDENT,AIRPLANE,INSTRUCTOR,TAKEOFF,LANDING,FILED,AREA,REASON
Regardless of whether output is None, this function will print out the number of
violations, as follows:
violations found.
If no violations are found, it will say
No violations found.
Parameter directory: The directory of files to audit
Precondition: directory is the name of a directory containing the files 'daycycle.json',
'weather.json', 'minimums.csv 'students.csv 'teachers.csv 'lessons.csv
'fleet.csv and 'repairs.csv
Parameter output: The CSV file to store the results
Precondition: output is None or a string that is a valid file name
listweatherviolations violations.listweatherviolationsdirectory
totalviolations lenlistweatherviolations
if totalviolations :
printNo violations found.
else:
violationviolations 'violation' if totalviolations else 'violations'
print ftotalviolationsviolationviolations found.
if output is not None:
header STUDENT"AIRPLANE","INSTRUCTOR","TAKEOFF","LANDING","FILED","AREA","REASON"
utils.writecsvheader listweatherviolations, output
def executeargs:
Executes the application or prints an error message if executed incorrectly.
The arguments to the application EXCLUDING the application name are provided to
the list args. This list should contain either or elements. If there is one
element, it should be the name of the data set folder or the value test'. If
there are two elements, the first should be the data set folder and the second
should be the name of a CSV file for output of the results
If the user calls this script incorrectly with the wrong number of arguments this
function prints:
Usage: python auditor dataset outputcsv
This function does not do much error checking beyond counting the number of arguments.
Parameter args: The command line arguments for the application minus the application name
Precondition: args is a list of strings
folders KITH 'KITH 'KITH
n lenargs
if n and n :
printUsage: python auditor dataset outputcsv
return
if n :
if argstest':
tests.testall
else:
printFolder name:", args
else:
foldername args
csvfilename args
if csvfilename is not None and csvfilename test' and not csvfilename.endswithcsv:
printUsage: python auditor dataset outputcsv
discoverviolationsfoldername, None
printUsage: python auditor dataset outputcsv
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
