Exemplo n.º 1
0
 def close(self):
     args = [string.join(self.__data, "")]
     if self.__encoding:
         args.append(self.__encoding)
     stdout, stderr = _elementtidy.fixup(*args)
     self.errlog = stderr
     return ElementTree.XML(stdout)
Exemplo n.º 2
0
 def close(self):
     args = [string.join(self.__data, "")]
     if self.__encoding:
         args.append(self.__encoding)
     stdout, stderr = _elementtidy.fixup(*args)
     self.errlog = stderr
     return ElementTree.XML(stdout)
Exemplo n.º 3
0
 def count_html_errors(self, html):
     """Run the HTML through a tidy process and count the number of complaint lines.
     Naive but a fine first pass.
     Should probably count Warning and Error differently.
     Could also use http://countergram.com/open-source/pytidylib/
     """
     xhtml, log = _elementtidy.fixup(html)
     #return len(log.splitlines())
     # return the *list* of errors, for rendering in JS as a popup
     return unicode(log, errors='ignore').splitlines()
Exemplo n.º 4
0
 def _validate_html (self, html):
     '''validate an html string with tidy and return a list of errors'''
     text = PoValidator.HEADER + html + PoValidator.FOOTER
     try:
         fixed_html, errors = _elementtidy.fixup(text)
     except UnicodeEncodeError:
         print 'Improper encoding settings. Please add the following lines to python2.6/sitecustomize.py:'
         print '    import sys'
         print "    sys.setdefaultencoding('iso-8859-1')"
         sys.exit(1)
     errors_list = errors.strip().split("\n")
     errors_list.pop(0)
     return errors_list
Exemplo n.º 5
0
 def close(self):
     data = _elementtidy.fixup(string.join(self.__data, ""))
     return ElementTree.XML(data)
Exemplo n.º 6
0
 def close(self):
     data = _elementtidy.fixup(string.join(self.__data, ""))
     return ElementTree.XML(data)
Exemplo n.º 7
0
 def _check_page_elementtidy(self):
     page = self._response.read()
     self._response.seek(0)        
     xhtml, log = _elementtidy.fixup(page)
     return log
Exemplo n.º 8
0
 def _check_page_elementtidy(self):
     page = self._response.read()
     self._response.seek(0)
     xhtml, log = _elementtidy.fixup(page)
     return log