Reference no: EM13261
Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command. This command will look at the contents of two directories and report on the differences between them. This includes those ?les that are only in one directory or the other, as well as ?les that have the same name, but have different characteristics as de?ned below.
The format of this command will be: diff [-R] [-c value] directory1 directory2
The options are as follows:
• -c value, determines what level of difference should be reported between two ?les. If not speci?ed, the default is to say that two ?les are the same if they have the same name and are not different types (?le vs. directory). If the option is speci?ed with a value of 1, then two ?les are only considered the same if they also have the same size. If the option is speci?ed with a value of 2, then two ?les are only considered the same if they have the same size and the same exact contents.
• -R, when present the contents of subdirectories with common names in each directory should also be analyzed in a recursive manner.
The report generated by the program should include three lists of ?les for every pair of directories (or subdirectories in the recursive case). The ?rst list contains those ?les only in directory1. The second list contains those ?les only in directory2. The third list contains those ?les that have the same name in each directory, but are considered different based on the -c option value. These lists should be sorted alphabetically. If a bad option is given to the command an error message should be displayed (including a bad value to the -c option). If anything other than two directories are speci?ed on the command line, an error message should be displayed.