parameters: (filename)
return_statement: return 0
docstring: Returns the gzipped size of a file, or 0 if file is not found.
docstring_summary: Returns the gzipped size of a file, or 0 if file is not found.
docstring_tokens: Returns the gzipped size of a file or 0 if file is not found .
function: def _get_gzipped_filesize(filename):
    """Returns the gzipped size of a file, or 0 if file is not found."""
    BUFFER_SIZE = 65536
    if not os.path.isfile(filename):
      return 0
    try:
      # Call gzip externally instead of using gzip package since it's > 2x faster.
      cmd = ['gzip', '-c', filename]
      p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
      # Manually counting bytes instead of using len(p.communicate()[0]) to avoid
      # buffering the entire compressed data (can be ~100 MB).
      ret = 0
      while True:
        chunk = len(p.stdout.read(BUFFER_SIZE))
        if chunk == 0:
          break
        ret += chunk
      return ret
    except OSError:
      logging.critical('Failed to get gzipped size: %s', filename)
    return 0
function_tokens: def _get_gzipped_filesize ( filename ) : BUFFER_SIZE = 65536 if not os . path . isfile ( filename ) : return 0 try : # Call gzip externally instead of using gzip package since it's > 2x faster. cmd = [ 'gzip' , '-c' , filename ] p = subprocess . Popen ( cmd , stdout = subprocess . PIPE ) # Manually counting bytes instead of using len(p.communicate()[0]) to avoid # buffering the entire compressed data (can be ~100 MB). ret = 0 while True : chunk = len ( p . stdout . read ( BUFFER_SIZE ) ) if chunk == 0 : break ret += chunk return ret except OSError : logging . critical ( 'Failed to get gzipped size: %s' , filename ) return 0