Skip to content

Commit

Permalink
add vnu --help (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Kreiss committed May 3, 2021
1 parent c1207d2 commit 81fbe36
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
13 changes: 12 additions & 1 deletion html5validator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
20 changes: 12 additions & 8 deletions html5validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()

Expand Down

0 comments on commit 81fbe36

Please sign in to comment.