# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+"""A rpmlint wrapper"""
+
import sys
import os
sys.path.insert(1, '/usr/share/rpmlint')
-from Filter import setRawOut, printed_messages, badnessThreshold, _badness_score
+from Filter import printed_messages, badnessThreshold
import SpecCheck
import Config
import Pkg
from common.git import clone_gitproject
def rpmlint(spec_file):
-
- def __print(s):
- pass
+ """Lint a spec file"""
def _print(msgtype, pkg, reason, details):
- global _badness_score
+ """Print datail information"""
threshold = badnessThreshold()
elif msgtype == 'E':
msgtype = 'W'
- ln = ""
+ line_num = ""
if pkg.current_linenum is not None:
- ln = "%s:" % pkg.current_linenum
+ line_num = "%s:" % pkg.current_linenum
arch = ""
if pkg.arch is not None:
arch = ".%s" % pkg.arch
- s = "%s%s:%s %s: %s" % (pkg.name, arch, ln, msgtype, reason)
+ state = "%s%s:%s %s: %s" % (pkg.name, arch, line_num, msgtype, reason)
if badness:
- s = s + " (Badness: %d)" % badness
- for d in details:
- s = s + " %s" % d
+ state = state + " (Badness: %d)" % badness
+ for detail in details:
+ state = state + " %s" % detail
else:
- if not Config.isFiltered(s):
- outputs.append(s)
+ if not Config.isFiltered(state):
+ outputs.append(state)
printed_messages[msgtype] += 1
- _badness_score += badness
if threshold >= 0:
- _diagnostic.append(s + "\n")
+ _diagnostic.append(state + "\n")
else:
- __print(s)
if Config.info:
printDescriptions(reason)
return True
return False
- Filter._print=_print
- #spec_file=sys.argv[1]
+ Filter._print = _print
+ # spec_file=sys.argv[1]
- # the tempfile is designed for python policycheck.py, bash script doesn't use it
+ # the tempfile is designed for python policycheck.py,
+ # bash script doesn't use it
rpmlint_prj = os.getenv('RPMLINT_PRJ')
git_cache_dir = os.getenv('GIT_CACHE_DIR')
check.check_spec(pkg, spec_file)
pkg.cleanup()
- msg = 'rpmlint checked %s: %d errors, %s warnings.' % (spec_file, printed_messages["E"], printed_messages["W"])
+ msg = 'rpmlint checked %s: %d errors, %s warnings.' % (
+ spec_file, printed_messages["E"], printed_messages["W"])
for line in outputs:
line = line.strip().lstrip(spec_file+':').strip()
if not line.startswith('W:') and not line.startswith('E:'):