parameters: (archiveFilePath, outputDir, expectedNumberOfExtractedFiles=None)
return_statement: return True
docstring: Extract file ``archiveFilePath`` into folder ``outputDir``.
  
    Number of expected files unzipped may be specified in ``expectedNumberOfExtractedFiles``.
    If folder contains the same number of files as expected (if specified), then it will be
    assumed that unzipping has been successfully done earlier.
docstring_summary: Extract file ``archiveFilePath`` into folder ``outputDir``.
docstring_tokens: Extract file archiveFilePath into folder outputDir .
function: def extractArchive(archiveFilePath, outputDir, expectedNumberOfExtractedFiles=None):
    """ Extract file ``archiveFilePath`` into folder ``outputDir``.
  
    Number of expected files unzipped may be specified in ``expectedNumberOfExtractedFiles``.
    If folder contains the same number of files as expected (if specified), then it will be
    assumed that unzipping has been successfully done earlier.
    """
    import os
    import logging
    from slicer import app
    if not os.path.exists(archiveFilePath):
      logging.error('Specified file %s does not exist' % (archiveFilePath))
      return False
    fileName, fileExtension = os.path.splitext(archiveFilePath)
    if fileExtension.lower() != '.zip':
      #TODO: Support other archive types
      logging.error('Only zip archives are supported now, got ' + fileExtension)
      return False
  
    numOfFilesInOutputDir = len(getFilesInDirectory(outputDir, False))
    if expectedNumberOfExtractedFiles is not None \
        and numOfFilesInOutputDir == expectedNumberOfExtractedFiles:
      logging.info(f'File {archiveFilePath} already unzipped into {outputDir}')
      return True
  
    extractSuccessful = app.applicationLogic().Unzip(archiveFilePath, outputDir)
    numOfFilesInOutputDirTest = len(getFilesInDirectory(outputDir, False))
    if extractSuccessful is False or (expectedNumberOfExtractedFiles is not None \
        and numOfFilesInOutputDirTest != expectedNumberOfExtractedFiles):
      logging.error(f'Unzipping {archiveFilePath} into {outputDir} failed')
      return False
    logging.info(f'Unzipping {archiveFilePath} into {outputDir} successful')
    return True
function_tokens: def extractArchive ( archiveFilePath , outputDir , expectedNumberOfExtractedFiles = None ) : import os import logging from slicer import app if not os . path . exists ( archiveFilePath ) : logging . error ( 'Specified file %s does not exist' % ( archiveFilePath ) ) return False fileName , fileExtension = os . path . splitext ( archiveFilePath ) if fileExtension . lower ( ) != '.zip' : #TODO: Support other archive types logging . error ( 'Only zip archives are supported now, got ' + fileExtension ) return False numOfFilesInOutputDir = len ( getFilesInDirectory ( outputDir , False ) ) if expectedNumberOfExtractedFiles is not None and numOfFilesInOutputDir == expectedNumberOfExtractedFiles : logging . info ( f'File {archiveFilePath} already unzipped into {outputDir}' ) return True extractSuccessful = app . applicationLogic ( ) . Unzip ( archiveFilePath , outputDir ) numOfFilesInOutputDirTest = len ( getFilesInDirectory ( outputDir , False ) ) if extractSuccessful is False or ( expectedNumberOfExtractedFiles is not None and numOfFilesInOutputDirTest != expectedNumberOfExtractedFiles ) : logging . error ( f'Unzipping {archiveFilePath} into {outputDir} failed' ) return False logging . info ( f'Unzipping {archiveFilePath} into {outputDir} successful' ) return True