parameters: (self, inf)
docstring: Attempts to shrink the PNG, if successful, returns True and
          overwrites the input file.
  
          Otherwise, returns false and does nothing
docstring_summary: Attempts to shrink the PNG, if successful, returns True and
          overwrites the input file.
docstring_tokens: Attempts to shrink the PNG if successful returns True and overwrites the input file .
function: def __call__(self, inf):
          """Attempts to shrink the PNG, if successful, returns True and
          overwrites the input file.
  
          Otherwise, returns false and does nothing
          """
          log('%s:' % (self._name))
          _file_handle1, temp_in = tempfile.mkstemp(self._name, 'png')
          os.close(_file_handle1)
          _file_handle2, temp_out = tempfile.mkstemp(self._name, 'png')
          os.close(_file_handle2)
  
          try:
              current_size = os.stat(inf).st_size
              shutil.copy(inf, temp_in)
  
              tool_process = subprocess.Popen([self._name] + self._options + [temp_in] +
                                              ([temp_out] if not self._inplace else []),
                                              stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  
              tool_process.wait()
  
              if tool_process.returncode:
                  output = tool_process.stdout.read()
                  if 'more than 256 colors' not in output:
                      raise RuntimeError('%s failed!: %s' %
                                         (self._name, tool_process.stdout.read()))
                  log('NO ')
              else:  # New file was written
                  new_size = os.stat(
                      temp_out if not self._inplace else temp_in).st_size
  
                  if new_size < current_size:
                      log('YES ')
                      shutil.copy(
                          temp_out if not self._inplace else temp_in, inf)
                  else:
                      log('NO ')
  
          finally:
              os.unlink(temp_in)
              os.unlink(temp_out)
function_tokens: def __call__ ( self , inf ) : log ( '%s:' % ( self . _name ) ) _file_handle1 , temp_in = tempfile . mkstemp ( self . _name , 'png' ) os . close ( _file_handle1 ) _file_handle2 , temp_out = tempfile . mkstemp ( self . _name , 'png' ) os . close ( _file_handle2 ) try : current_size = os . stat ( inf ) . st_size shutil . copy ( inf , temp_in ) tool_process = subprocess . Popen ( [ self . _name ] + self . _options + [ temp_in ] + ( [ temp_out ] if not self . _inplace else [ ] ) , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) tool_process . wait ( ) if tool_process . returncode : output = tool_process . stdout . read ( ) if 'more than 256 colors' not in output : raise RuntimeError ( '%s failed!: %s' % ( self . _name , tool_process . stdout . read ( ) ) ) log ( 'NO ' ) else : # New file was written new_size = os . stat ( temp_out if not self . _inplace else temp_in ) . st_size if new_size < current_size : log ( 'YES ' ) shutil . copy ( temp_out if not self . _inplace else temp_in , inf ) else : log ( 'NO ' ) finally : os . unlink ( temp_in ) os . unlink ( temp_out )