This week we went over file compression and the use of modules, including the zipfile, zlib and os modules.
The best solution for each assignment below will be added to our ASG Python Library (http://asg.ise.com/tap/ASG_Library_Keywords_Docs.html). A combination between the cleanest code, the most user friendly output and best functionality will determine the winners.
Lab Assignment:
Create a function called 'compress_file_using_zip' that takes in
two arguments: directory, filename
Use os.listdir() to search through the specified directory
Verify the requested filename is found by os.listdir()
Create a Zipfile object to create the zipfile
The zipfile name should be the filename + .zip extension
Print only three lines if successful:
1) One line introducing the function
2) Once you find the file to compress, print:
Compress file: <filename>
3) Once done compressing file, print:
Created zip archive: <zipfile name>
Print only two lines if failed:
1) One line introducing the function
2) If the file was not found, print:
Did not find <DIR+FILENAME> to compress
Return True inside conditional if successful
Return False inside conditional if failed
Homework Assignment:
Create a new function called: 'compress_files_by_extension_using_zip'.
- This function will take in 3 arguments: directory, extension, archive_name
- This function will search through the specified 'directory' and compress all files of the
specified 'extension' using zip. The name of this zip archive will be specified by the
'archive_name'.
BONUS Assignments:
Create a new function called: 'compress_directory_using_zip'
- This function will take 2 arguments: directory, archive_name
- This function will compress the specified directory and store it as a zip file according
to the specified 'archive_name'. If 'archive_name' is not specified, the zip archive should
be: folder+'.zip'
Create a new function called: 'compress_files_by_size_using_zip'
- This function will take 3 arguments: directory, size, archive_name
- This function will compress all files in the specified 'directory' which are greater than
or equal to the 'size' specified by the user. The name of the zip archive will be determined
by 'archive_name'
This week we went over file compression and the use of modules, including the zipfile, zlib and os modules.
The best solution for each assignment below will be added to our ASG Python Library (http://asg.ise.com/tap/ASG_Library_Keywords_Docs.html). A combination between the cleanest code, the most user friendly output and best functionality will determine the winners.
Lab Assignment:
Homework Assignment:
BONUS Assignments:
@vraghunandan @bdambola @kwokman @dsapienza @DRozentsvay @gganeshan @cbautista1002 @xingj53 @wcorrea @rklotz @isehgu @akbamaa