code: def validate(filename):
      
      import HTMLParser
      from py_w3c.validators.html.validator import HTMLValidator
  
      h = HTMLParser.HTMLParser()  # for unescaping WC3 messages
  
      vld = HTMLValidator()
      LOG.info("Validating: {0}".format(filename))
  
      # call w3c webservice
      vld.validate_file(filename)
  
      # display errors and warning
      for err in vld.errors:
          LOG.error(u'line: {0}; col: {1}; message: {2}'.
                    format(err['line'], err['col'], h.unescape(err['message']))
                    )
      for err in vld.warnings:
          LOG.warning(u'line: {0}; col: {1}; message: {2}'.
                      format(err['line'], err['col'], h.unescape(err['message']))
                      )
docs: Use W3C validator service: https://bitbucket.org/nmb10/py_w3c/ .
      :param filename: the filename to validate