home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import cgi
- import os
- import StringIO
- import traceback
- import cherrypy
-
- def tidy(temp_dir, tidy_path, strict_xml = False, errors_to_ignore = None, indent = False, wrap = False, warnings = True):
- response = cherrypy.response
- orig_body = response.collapse_body()
- fct = response.headers.get('Content-Type', '')
- ct = fct.split(';')[0]
- encoding = ''
- i = fct.find('charset=')
- if i != -1:
- encoding = fct[i + 8:]
-
- if use_output:
- response.body = [
- output]
- if response.headers.has_key('Content-Length'):
- del response.headers['Content-Length']
-
-
- ct == 'text/html' if ct == 'text/html' else new_errs
-
-
- def html_space(text):
- return cgi.escape(text).replace('\t', ' ').replace(' ', ' ')
-
-
- def html_break(text):
- return cgi.escape(text).replace('\n', '<br />')
-
-
- def wrong_content(header, body, content_type = 'HTML'):
- output = [
- 'Wrong %s:<br />%s<br />' % (content_type, html_break(header))]
- for i, line in enumerate(body.splitlines()):
- output.append('%03d - %s' % (i + 1, html_space(line)))
-
- return '<br />'.join(output)
-
-
- def nsgmls(temp_dir, nsgmls_path, catalog_path, errors_to_ignore = None):
- response = cherrypy.response
- orig_body = response.collapse_body()
- fct = response.headers.get('Content-Type', '')
- ct = fct.split(';')[0]
- encoding = ''
- i = fct.find('charset=')
- if i != -1:
- encoding = fct[i + 8:]
-
- if ct == 'text/html':
- while True:
- i = orig_body.find('<script')
- if i == -1:
- break
-
- j = orig_body.find('</script>', i)
- if j == -1:
- break
-
- orig_body = orig_body[:i] + orig_body[j + 9:]
- page_file = os.path.join(temp_dir, 'page.html')
- open(page_file, 'wb').write(orig_body)
- err_file = os.path.join(temp_dir, 'nsgmls.err')
- command = '%s -c%s -f%s -s -E10 %s' % (nsgmls_path, catalog_path, err_file, page_file)
- command = command.replace('\\', '/')
- os.system(command)
- errs = open(err_file, 'rb').read()
- new_errs = []
- for err in errs.splitlines():
- ignore = False
- for err_ign in []:
- if err.find(err_ign) != -1:
- ignore = True
- break
- continue
- elif not ignore:
- new_errs.append(err)
- continue
- if new_errs:
- response.body = wrong_content('<br />'.join(new_errs), orig_body)
- if response.headers.has_key('Content-Length'):
- del response.headers['Content-Length']
-
-
- new_errs
-
-