Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
This function uncompress the file, and return
the extension for the uncompressed file.

        def uncompress_file(filepath, extension, output_dir=None):
    """This function uncompress the file, and return
    the extension for the uncompressed file."""

    if not output_dir:
        output_dir = tempfile.mkdtemp()

    basename = os.path.basename(filepath)
    # Get new path to the uncompressed file
    new_filepath = os.path.join(output_dir, basename)

    extractor = FileExtractor()
    files = []

    if extension in COMPRESSED_TYPES:
        shutil.copy(filepath, output_dir)

    # Return a list of all the uncompressed files
    if '.zip' == extension:
        files = extractor.zipExtraction(new_filepath)
    elif extension in ['.tar', '.tar.gz', '.tgz', '.tar.bz2', '.tbz']:
        files = extractor.tarExtraction(new_filepath)
    elif '.gz' == extension:
        # Return a list with only 1 element (the method returns a string)
        files = [extractor.gzExtraction(new_filepath)]
    elif '.bz2' == extension:
        # Return a list with only 1 element (the method returns a string)
        files = [extractor.bz2Extraction(new_filepath)]

    # We copied the compressed file to outputdir to uncompress it,
    # now we need to remove it and leave only the uncompressed file(s)
    if os.path.exists(new_filepath):
        os.unlink(new_filepath)

    return files
        


src/m/a/MailingListStats-HEAD/pymlstats/main.py   MailingListStats(Download)
from analyzer import MailArchiveAnalyzer
from htmlparser import MyHTMLParser
from utils import find_current_month, create_dirs, mlstats_dot_dir,\
    retrieve_remote_file, check_compressed_file, uncompress_file
 
            if archive.is_compressed():
                # Uncompress and get the raw filepaths
                filepaths = uncompress_file(archive.filepath,
                                            archive.compressed_type,
                                            mailing_list.mbox_dir)