Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import gzip
- import shutil
- def gunzip_shutil(source_filepath, dest_filepath, block_size=65536):
- '''
- TODO: Version with path handling:
- dest = source minus suffix
- TODO: try/except
- TODO: controls (file exists)
- TODO: return values
- TODO: Documentation
- '''
- with gzip.open(source_filepath, 'rb') as s_file, \
- open(dest_filepath, 'wb') as d_file:
- shutil.copyfileobj(s_file, d_file, block_size)
- file_in = sys.argv[1]
- filename, file_extension = os.path.splitext(file_in)
- print(file_in)
- print(filename)
- gunzip_shutil(file_in, filename)
- # with gzip.open(file_in, 'rb') as f_in:
- # with open(filename, 'wb') as f_out:
- # shutil.copyfileobj(f_in, f_out)
- # def gzip_shutil(source_filepath, dest_filepath, block_size=65536):
- # '''
- # TODO: Version with path handling:
- # dest = source plus suffix (*.gz)
- # TODO: try/except
- # TODO: controls (file exists)
- # TODO: return values
- # TODO: Documentation
- # '''
- # with gzip.open(dest_filepath, 'wb') as f_out:
- # with open(source_filepath, 'rb') as f_in:
- # shutil.copyfileobj(f_in, f_out)
- # gzip_shutil(filename, file_in)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement