def run_tidy(html):
 global _tidy_cmd, _tidy_exists
 from commands import _options
 require_tidy = _options.get('require_tidy')
 if (not _tidy_exists):
  if require_tidy:
   raise TwillException('tidy does not exist and require_tidy is set')
  return (None, None)
 clean_html = None
 if _tidy_exists:
  try:
   process = subprocess.Popen(_tidy_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0, shell=False)
   (stdout, stderr) = process.communicate(html)
   clean_html = stdout
   errors = stderr
  except OSError:
   _tidy_exists = False
 errors = None
 if (require_tidy and (clean_html is None)):
  raise TwillException('tidy does not exist and require_tidy is set')
 return (clean_html, errors)

def run_tidy ( html ) : global _tidy_cmd , _tidy_exists from commands import _options require_tidy = _options . get ( 'require_tidy' ) if ( not _tidy_exists ) : if require_tidy : raise TwillException ( 'tidy does not exist and require_tidy is set' ) return ( None , None ) clean_html = None if _tidy_exists : try : process = subprocess . Popen ( _tidy_cmd , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE , bufsize = 0 , shell = False ) ( stdout , stderr ) = process . communicate ( html ) clean_html = stdout errors = stderr except OSError : _tidy_exists = False errors = None if ( require_tidy and ( clean_html is None ) ) : raise TwillException ( 'tidy does not exist and require_tidy is set' ) return ( clean_html , errors )
run the tidy command-line program on the given html string .