$29
In this assignment, you enhance your code from Week 6.
Please follow the steps outlined below.
Preparation
Step 1: Configure logging module
In autompg2.py configure the logging module as shown in the lecture so that it logs at the DEBUG level into file autompg2.log and to the console at level INFO. Go back through the code in autompg2.py and add logging calls at appropriate places. As new code is written in this assignment, add logging calls as you go.
Step 2: Add sorting to AutoMPGData class
Enhance the AutoMPGData class by adding the following methods:
Step 3: Add capability to download Internet data
Enhance the AutoMPGData class by adding the _get_data method. Please follow these guidelines for this method:
Test this functionality by removing the local data file and executing autompg2.py. It should download the data and then work as before.
Step 4: Enhance command-line parsing
In autompg2.py use the argparse module to implement enhanced command-line parsing for this program. The program should support the usage shown below. The only “command” supported is “print”, which will iterate over the elements of the AutoMPGData collection (as it is sorted) and print each one. The options to the “sort order” are “year”, “mpg”, and “default”, and the result of these options is to call the corresponding “sort_by_XXX” method on the AutoMPGData object before the data are printed.
usage: autompg2.py [-h] [-s <sort order>] <command>
analyze Auto MPG data set
positional arguments:
<command>
command to execute
optional arguments:
-h, --help show this help message and exit
-s <sort order>, --sort <sort order>
Upload
Please put autompg2.py into a ZIP file.