#!/usr/bin/env python

"""
Check code with PyLint and view HTML output.

Usage: See pylint --help.
"""

import os
import sys
import tempfile

TOOL_DIR = os.path.dirname(os.path.abspath(__file__))
LIB_DIR  = os.path.join(TOOL_DIR, '..', 'lib')
os.environ['PYTHONPATH'] = LIB_DIR + ':' + os.environ['PYTHONPATH']
sys.path.insert(0, LIB_DIR)

from gaupol.base.util import wwwlib
report = os.path.join(tempfile.gettempdir(), 'gaupol.pylint')
fobj = os.popen('pylint %s' % ' '.join(sys.argv[1:]))
output = fobj.read()
fobj.close()
fobj = open(report, 'w')
fobj.write(output)
fobj.close()
wwwlib.browse_url(report)
