From 81fbe36827a3dd0b7100cd4787dac1b167e4a32f Mon Sep 17 00:00:00 2001 From: Sven Kreiss Date: Mon, 3 May 2021 09:21:12 +0200 Subject: [PATCH] add vnu --help (#84) --- html5validator/cli.py | 13 ++++++++++++- html5validator/validator.py | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/html5validator/cli.py b/html5validator/cli.py index b113c84..649b498 100644 --- a/html5validator/cli.py +++ b/html5validator/cli.py @@ -35,9 +35,20 @@ def parse_yaml(filename, starter): def main(): """Main function of html5validator""" + vnu_help, _ = Validator().run_vnu(['--help']) + parser = argparse.ArgumentParser( description='[v' + VERSION + '] ' + __doc__, - prog='html5validator' + prog='html5validator', + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=''' + +This html5validator uses vnu.jar to check the files. +It has many options that are documented in the +vnu.jar help below. + +================= VNU help ======================== + ''' + vnu_help, ) parser.add_argument('files', nargs='*', default=None, help='specify files to check') diff --git a/html5validator/validator.py b/html5validator/validator.py index d3602d2..aa9d9f1 100644 --- a/html5validator/validator.py +++ b/html5validator/validator.py @@ -138,15 +138,11 @@ def _vnu_options(self): return vnu_options - def validate(self, files): - if sys.platform == 'cygwin': - files = [_cygwin_path_convert(f) for f in files] - + def run_vnu(self, arguments): try: cmd = (['java'] + self._java_options() + ['-jar', self.vnu_jar_location] - + self._vnu_options() - + files) + + arguments) LOGGER.debug(cmd) p = subprocess.Popen( cmd, @@ -162,9 +158,17 @@ def validate(self, files): except subprocess.CalledProcessError as error: raise (error.output.decode('utf-8')) + return stdout.decode('utf-8'), stderr.decode('utf-8') + + def validate(self, files): + if sys.platform == 'cygwin': + files = [_cygwin_path_convert(f) for f in files] + + stdout, stderr = self.run_vnu(self._vnu_options() + files) + # process fancy quotes into standard quotes - stdout = _normalize_string(stdout.decode('utf-8')) - stderr = _normalize_string(stderr.decode('utf-8')) + stdout = _normalize_string(stdout) + stderr = _normalize_string(stderr) err = stdout.splitlines() + stderr.splitlines()