flake8 cleanups

This commit is contained in:
Ville Skyttä 2014-05-29 21:50:58 +03:00
parent b2bc56a5c6
commit 543a05f084
23 changed files with 8398 additions and 8308 deletions

View File

@ -21,9 +21,12 @@ import Config
# Note: do not add any capturing parentheses here
macro_regex = re.compile('%+[{(]?[a-zA-Z_]\w{2,}[)}]?')
class _HeadRequest(urllib2.Request):
def get_method(self):
return "HEAD"
class _HeadRedirectHandler(urllib2.HTTPRedirectHandler):
def redirect_request(*args):
res = urllib2.HTTPRedirectHandler.redirect_request(*args)
@ -31,6 +34,7 @@ class _HeadRedirectHandler(urllib2.HTTPRedirectHandler):
res = _HeadRequest(res.get_full_url())
return res
class AbstractCheck:
known_checks = {}
@ -86,17 +90,18 @@ class AbstractCheck:
res.close()
return info
class AbstractFilesCheck(AbstractCheck):
def __init__(self, name, file_regexp):
self.__files_re = re.compile(file_regexp)
AbstractCheck.__init__(self, name)
def check_binary(self, pkg):
ghosts = pkg.ghostFiles()
for filename in (x for x in pkg.files() if x not in ghosts):
if self.__files_re.match(filename):
self.check_file(pkg, filename)
def check_file(self, pkg, filename):
"""Virtual method called for each file that match the regexp passed
to the constructor.

View File

@ -24,12 +24,14 @@ DEFAULT_SYSTEM_LIB_PATHS = (
'/lib', '/usr/lib', '/usr/X11R6/lib',
'/lib64', '/usr/lib64', '/usr/X11R6/lib64')
def create_regexp_call(call):
if type(call) == type([]):
call = '(?:' + '|'.join(call) + ')'
r = "\s+FUNC\s+.*?\s+(%s(?:@GLIBC\S+)?)(?:\s|$)" % call
return re.compile(r)
class BinaryInfo:
needed_regex = re.compile('\s+\(NEEDED\).*\[(\S+)\]')
@ -247,6 +249,7 @@ srcname_regex = re.compile('(.*?)-[0-9]')
invalid_dir_ref_regex = re.compile('/(home|tmp)(\W|$)')
ocaml_mixed_regex = re.compile('^Caml1999X0\d\d$')
def dir_base(path):
res = path_regex.search(path)
if res:
@ -254,6 +257,7 @@ def dir_base(path):
else:
return '', path
class BinariesCheck(AbstractCheck.AbstractCheck):
def __init__(self):
@ -423,7 +427,8 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
continue
if not bin_info.needed and not (
bin_info.soname and ldso_soname_regex.search(bin_info.soname)):
bin_info.soname and
ldso_soname_regex.search(bin_info.soname)):
if is_shobj:
printError(pkg,
'shared-lib-without-dependency-information',
@ -434,8 +439,8 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
else:
# linked against libc ?
if "libc." not in fname and \
(not bin_info.soname or \
("libc." not in bin_info.soname and \
(not bin_info.soname or
("libc." not in bin_info.soname and
not ldso_soname_regex.search(bin_info.soname))):
found_libc = False
@ -456,7 +461,8 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
if bin_info.exec_stack:
printWarning(pkg, 'executable-stack', fname)
elif not bin_info.readelf_error and (
pkg.arch.endswith("86") or pkg.arch.startswith("pentium") or
pkg.arch.endswith("86") or
pkg.arch.startswith("pentium") or
pkg.arch in ("athlon", "x86_64")):
printError(pkg, 'missing-PT_GNU_STACK-section', fname)

View File

@ -56,20 +56,24 @@ no_exception = False
_checks = []
_checks.extend(DEFAULT_CHECKS)
def addCheck(check):
check = re.sub('\.py[co]?$', '', check)
if check not in _checks:
_checks.append(check)
def allChecks():
if _checks == []:
defaultChecks()
return _checks
def defaultChecks():
resetChecks()
_checks.extend(DEFAULT_CHECKS)
def resetChecks():
global _checks
@ -79,11 +83,13 @@ def resetChecks():
_dirs = ["/usr/share/rpmlint"]
def addCheckDir(dir):
d = os.path.expanduser(dir)
if d not in _dirs:
_dirs.insert(0, d)
def checkDirs():
return _dirs
@ -91,9 +97,11 @@ def checkDirs():
_options = {}
def setOption(name, value):
_options[name] = value
def getOption(name, default=""):
try:
return _options[name]
@ -104,12 +112,14 @@ def getOption(name, default = ""):
_filters = []
_filters_re = None
def addFilter(s):
global _filters_re
_filters.append(s)
_filters_re = None
def removeFilter(s):
global _filters_re
@ -122,17 +132,21 @@ def removeFilter(s):
_scoring = {}
def setBadness(s, score):
_scoring[s] = score
def badness(s):
return _scoring.get(s, 0)
_non_named_group_re = re.compile('[^\\](\()[^:]')
def isFiltered(s):
global _filters_re
if _filters_re == None:
if _filters_re is None:
# no filter
if len(_filters) == 0:
return False

View File

@ -22,8 +22,8 @@ vendor = Config.getOption("Vendor")
distribution = Config.getOption("Distribution")
compress_ext = Config.getOption("CompressExtension", "bz2")
class DistributionCheck(AbstractCheck.AbstractCheck):
class DistributionCheck(AbstractCheck.AbstractCheck):
def __init__(self):
AbstractCheck.AbstractCheck.__init__(self, "DistributionCheck")
@ -65,7 +65,7 @@ addDetails(
automatically when the package is rebuilt, make sure that you have the
appropriate rpm helper and/or config packages for your target distribution
installed and try rebuilding again; if it still does not happen automatically,
you can compress this file in the %%install section of the spec file.''' \
you can compress this file in the %%install section of the spec file.'''
% (compress_ext, compress_ext),
'infopage-not-compressed',
@ -74,7 +74,7 @@ you can compress this file in the %%install section of the spec file.''' \
automatically when the package is rebuilt, make sure that you have the
appropriate rpm helper and/or config packages for your target distribution
installed and try rebuilding again; if it still does not happen automatically,
you can compress this file in the %%install section of the spec file.''' \
you can compress this file in the %%install section of the spec file.'''
% (compress_ext, compress_ext),
)

View File

@ -261,6 +261,7 @@ else:
# Python 3 means bytes accepts integer input directly
printable_extended_ascii += bytes(range(32, 256))
def peek(filename, pkg, length=1024):
"""Peek into a file, return a chunk from its beginning and a flag if it
seems to be a text file."""
@ -316,6 +317,7 @@ _python_magic_values = {
'3.4': 3310,
}
def get_expected_pyc_magic(path):
""".pyc/.pyo files embed a 4-byte magic value identifying which version of
the python bytecode ABI they are for. Given a path to a .pyc/.pyo file,
@ -347,6 +349,7 @@ def get_expected_pyc_magic(path):
return (expected_magic_value, ver_from_path)
def py_demarshal_long(b):
"""Counterpart to Python's PyMarshal_ReadLongFromFile, operating on the
bytes in a string."""
@ -357,6 +360,7 @@ def py_demarshal_long(b):
+ (b[2] << 16)
+ (b[3] << 24))
def python_bytecode_to_script(path):
"""Given a python bytecode path, give the path of the .py file
(or None if not python bytecode)."""
@ -371,6 +375,7 @@ def python_bytecode_to_script(path):
return None
class FilesCheck(AbstractCheck.AbstractCheck):
def __init__(self):
@ -452,7 +457,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
is_kernel_package:
printError(pkg, "kernel-modules-not-in-kernel-packages", f)
for i in ['mnt','opt','usr-local','var-local','home']:
for i in ('mnt', 'opt', 'usr-local', 'var-local', 'home'):
if f.startswith('/%s/' % i.replace('-', '/')):
printError(pkg, 'dir-or-file-in-%s' % i, f)
@ -644,8 +649,8 @@ class FilesCheck(AbstractCheck.AbstractCheck):
bindir_exes.setdefault(exe, []).append(f)
if not devel_pkg and not is_doc and \
(includefile_regex.search(f) or \
develfile_regex.search(f) or is_buildconfig):
(includefile_regex.search(f) or develfile_regex.search(f) or
is_buildconfig):
printWarning(pkg, 'devel-file-in-non-devel-package', f)
if mode & int("444", 8) != int("444", 8) and \
perm & int("7000", 8) == 0:
@ -853,7 +858,6 @@ class FilesCheck(AbstractCheck.AbstractCheck):
if hidden_file_regex.search(f):
printWarning(pkg, 'hidden-file-or-dir', f)
# symbolic link check
elif stat.S_ISLNK(mode):

View File

@ -32,15 +32,19 @@ else:
s = s.encode(locale.getpreferredencoding(), "replace")
print(s)
def printInfo(pkg, reason, *details):
_print("I", pkg, reason, details)
def printWarning(pkg, reason, *details):
_print("W", pkg, reason, details)
def printError(pkg, reason, *details):
_print("E", pkg, reason, details)
def _print(msgtype, pkg, reason, details):
global _badness_score
@ -85,6 +89,7 @@ def _print(msgtype, pkg, reason, details):
return False
def printDescriptions(reason):
try:
d = _details[reason]
@ -94,10 +99,12 @@ def printDescriptions(reason):
except KeyError:
pass
def _diag_sortkey(x):
xs = x.split()
return (xs[2], xs[1])
def printAllReasons():
threshold = badnessThreshold()
if threshold < 0:
@ -122,17 +129,21 @@ def printAllReasons():
_details = {}
def addDetails(*details):
for idx in range(int(len(details)/2)):
if not details[idx*2] in _details:
_details[details[idx*2]] = details[idx*2+1]
def badnessScore():
return _badness_score
def badnessThreshold():
return Config.getOption("BadnessThreshold", -1)
def setRawOut(file):
global _rawout
if _rawout:

View File

@ -46,6 +46,7 @@ EXCEPTION_DIRS = ('C', 'POSIX', 'CP1251', 'CP1255', 'CP1256',
'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15',
'KOI8-R', 'KOI8-U', 'UTF-8', 'default')
def is_valid_lang(lang):
# TODO: @Foo and charset handling
lang = re.sub("[@.].*$", "", lang)
@ -69,6 +70,7 @@ def is_valid_lang(lang):
return True
class I18NCheck(AbstractCheck.AbstractCheck):
def __init__(self):
@ -150,6 +152,7 @@ class I18NCheck(AbstractCheck.AbstractCheck):
if locales not in (x[0] for x in pkg.requires()):
printError(pkg, 'no-dependency-on', locales)
def is_prefix(p, s):
return len(p) <= len(s) and p == s[:len(p)]

View File

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
#---------------------------------------------------------------
#############################################################################
# Project : Mandriva Linux
# Module : rpmlint
# File : InitScriptCheck.py
# Author : Frederic Lepied
# Created On : Fri Aug 25 09:26:37 2000
# Purpose : check init scripts (files in /etc/rc.d/init.d)
#---------------------------------------------------------------
#############################################################################
import os
import re
@ -36,6 +36,7 @@ LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop', 'Should-Start',
RECOMMENDED_LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop',
'Default-Stop', 'Short-Description')
class InitScriptCheck(AbstractCheck.AbstractCheck):
def __init__(self):

View File

@ -1,25 +1,25 @@
# -*- coding: utf-8 -*-
#---------------------------------------------------------------
#############################################################################
# Project : Mandriva Linux
# Module : rpmlint
# File : LSBCheck.py
# Author : Frederic Lepied
# Created On : Tue Jan 30 14:44:37 2001
# Purpose : LSB non compliance checks
#---------------------------------------------------------------
#############################################################################
import re
import rpm
from Filter import addDetails, printError
from Pkg import b2s
import AbstractCheck
version_regex = re.compile('^[a-zA-Z0-9.+]+$')
name_regex = re.compile('^[a-z0-9.+-]+$')
class LSBCheck(AbstractCheck.AbstractCheck):
def __init__(self):

View File

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
#---------------------------------------------------------------
#############################################################################
# Project : Mandriva Linux
# Module : rpmlint
# File : MenuCheck.py
# Author : Frederic Lepied
# Created On : Mon Mar 20 07:43:37 2000
#---------------------------------------------------------------
#############################################################################
import re
import stat
@ -154,6 +154,7 @@ for l in launchers:
l[0] = re.compile(l[0])
del l
class MenuCheck(AbstractCheck.AbstractCheck):
def __init__(self):

View File

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
#---------------------------------------------------------------
#############################################################################
# Project : Mandriva Linux
# Module : rpmlint
# File : NamingPolicyCheck.py
# Author : Michael Scherer
# Created On : Mon May 19 11:25:37 2003
# Purpose : Check package names according to their content.
#---------------------------------------------------------------
#############################################################################
import re
@ -28,9 +28,11 @@ import AbstractCheck
simple_naming_policy_re = re.compile('\^[a-zA-Z1-9-_]*$')
class NamingPolicyNotAppliedException(Exception):
pass
class NamingPolicyCheck(AbstractCheck.AbstractCheck):
checks_ = []

View File

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
#---------------------------------------------------------------
#############################################################################
# Project : Mandriva Linux
# Module : rpmlint
# File : PamCheck.py
# Author : Michael Scherer
# Created On : 31/01/2006
# Purpose : Apply pam policy
#---------------------------------------------------------------
#############################################################################
import re
@ -16,6 +16,7 @@ import AbstractCheck
pam_stack_re = re.compile('^\s*[^#].*pam_stack\.so\s*service')
class PamCheck(AbstractCheck.AbstractFilesCheck):
def __init__(self):
AbstractCheck.AbstractFilesCheck.__init__(self, "PamCheck",

26
Pkg.py
View File

@ -37,6 +37,7 @@ if sys.version_info[0] > 2:
# Blows up with Python < 3 without the exec() hack
exec('def warn(s): print (s, file=sys.stderr)')
long = int
def b2s(b):
if b is None:
return None
@ -44,7 +45,9 @@ if sys.version_info[0] > 2:
return [b2s(x) for x in b]
return b.decode(errors='replace')
else:
def warn(s): print >> sys.stderr, s
def warn(s):
print >> sys.stderr, s
def b2s(b):
return b
@ -61,6 +64,7 @@ PREREQ_FLAG = (rpm.RPMSENSE_PREREQ or 64) | \
var_regex = re.compile('^(.*)\${?(\w+)}?(.*)$')
def shell_var_value(var, script):
assign_regex = re.compile('\\b' + re.escape(var) + '\s*=\s*(.+)\s*(#.*)*$',
re.MULTILINE)
@ -74,6 +78,7 @@ def shell_var_value(var, script):
else:
return None
def substitute_shell_vars(val, script):
res = var_regex.search(val)
if res:
@ -85,6 +90,7 @@ def substitute_shell_vars(val, script):
else:
return val
def getstatusoutput(cmd, stdoutonly=False, shell=False):
'''A version of commands.getstatusoutput() which can take cmd as a
sequence, thus making it potentially more secure.'''
@ -107,6 +113,7 @@ def getstatusoutput(cmd, stdoutonly = False, shell = False):
bz2_regex = re.compile('\.t?bz2?$')
xz_regex = re.compile('\.(t[xl]z|xz|lzma)$')
def catcmd(fname):
"""Get a 'cat' command that handles possibly compressed files."""
cat = 'gzip -dcf'
@ -116,12 +123,14 @@ def catcmd(fname):
cat = 'xz -dc'
return cat
def is_utf8(fname):
(sts, text) = getstatusoutput(catcmd(fname).split() + [fname])
return not sts and is_utf8_str(text)
REPLACEMENT_CHAR = unicodedata.lookup('REPLACEMENT CHARACTER')
def is_utf8_str(s):
if hasattr(s, 'decode'):
# byte string
@ -133,6 +142,7 @@ def is_utf8_str(s):
# unicode string
return REPLACEMENT_CHAR not in s
# TODO: PY3
def to_utf8(string):
if string is None:
@ -160,6 +170,7 @@ def to_utf8(string):
newstring = newstring + char
return newstring
def readlines(path):
fobj = open(path, 'rb')
try:
@ -168,6 +179,7 @@ def readlines(path):
finally:
fobj.close()
def mktemp():
tmpfd, tmpname = tempfile.mkstemp(prefix='rpmlint.')
tmpfile = os.fdopen(tmpfd, 'w')
@ -177,6 +189,7 @@ slash_regex = re.compile('/+')
slashdot_regex = re.compile('/(\.(/|$))+')
slashend_regex = re.compile('([^/])/+$')
def safe_normpath(path):
"""Like os.path.normpath but normalizes less aggressively thus being
potentially safer for paths containing symlinks."""
@ -185,6 +198,7 @@ def safe_normpath(path):
ret = slashend_regex.sub('\\1', ret)
return ret
def get_default_valid_rpmgroups(filename=None):
"""Get default rpm groups from filename, or try to look them up from
the rpm package (if installed) if no filename is given"""
@ -211,6 +225,7 @@ def get_default_valid_rpmgroups(filename = None):
groups.sort()
return groups
# from yum 3.2.27, rpmUtils.miscutils, with rpmlint modifications
def compareEVR(evr1, evr2):
(e1, v1, r1) = evr1
@ -230,6 +245,7 @@ def compareEVR(evr1, evr2):
rc = rpm.labelCompare((e1, v1, r1), (e2, v2, r2))
return rc
# from yum 3.2.27, rpmUtils.miscutils, with rpmlint modifications
def rangeCompare(reqtuple, provtuple):
"""returns true if provtuple satisfies reqtuple"""
@ -307,6 +323,7 @@ def rangeCompare(reqtuple, provtuple):
return 0
# from yum 3.2.23, rpmUtils.miscutils, with rpmlint modifications
def formatRequire(name, flags, evr):
s = name
@ -324,6 +341,7 @@ def formatRequire(name, flags, evr):
s = "%s %s" % (s, versionToString(evr))
return s
def versionToString(evr):
if not isinstance(evr, (list, tuple)):
# assume string
@ -337,6 +355,7 @@ def versionToString(evr):
ret += "-" + evr[2]
return ret
# from yum 3.2.23, rpmUtils.miscutils, with some rpmlint modifications
def stringToVersion(verstring):
if verstring in (None, ''):
@ -365,6 +384,7 @@ def stringToVersion(verstring):
release = None
return (epoch, version, release)
def parse_deps(line):
'''Parse provides/requires/conflicts/obsoletes line to list of
(name, flags, (epoch, version, release)) tuples.'''
@ -784,6 +804,7 @@ class Pkg:
prog = b' '.join(prog)
return b2s(prog)
def getInstalledPkgs(name):
"""Get list of installed package objects by name."""
@ -800,6 +821,7 @@ def getInstalledPkgs(name):
return pkgs
# Class to provide an API to an installed package
class InstalledPkg(Pkg):
def __init__(self, name, hdr=None):
@ -827,6 +849,7 @@ class InstalledPkg(Pkg):
def checkSignature(self):
return (0, 'fake: pgp md5 OK')
# Class to provide an API to a "fake" package, eg. for specfile-only checks
class FakePkg:
def __init__(self, name):
@ -837,6 +860,7 @@ class FakePkg:
def cleanup(self):
pass
# Class for files in packages
class PkgFile(object):

View File

@ -72,12 +72,15 @@ script_tags = [
(rpm.RPMTAG_VERIFYSCRIPT, rpm.RPMTAG_VERIFYSCRIPTPROG, '%verifyscript'),
]
def incorrect_shell_script(prog, shellscript):
return check_syntax_script(prog, '-n', shellscript)
def incorrect_perl_script(prog, perlscript):
return check_syntax_script(prog, '-wc', perlscript)
def check_syntax_script(prog, commandline, script):
if not script:
return False

View File

@ -20,8 +20,8 @@ source_regex = re.compile('\\.(tar|patch|tgz|diff)$')
compress_ext = Config.getOption("CompressExtension", "bz2")
valid_src_perms = Config.getOption("ValidSrcPerms", DEFAULT_VALID_SRC_PERMS)
class SourceCheck(AbstractCheck.AbstractCheck):
class SourceCheck(AbstractCheck.AbstractCheck):
def __init__(self):
AbstractCheck.AbstractCheck.__init__(self, 'SourceCheck')

View File

@ -31,14 +31,13 @@ DEFAULT_BIARCH_PACKAGES = '^(gcc|glibc)'
# be installed on biarch systems
DEFAULT_HARDCODED_LIB_PATH_EXCEPTIONS = '/lib/(modules|cpp|perl5|rpm|hotplug|firmware)($|[\s/,])'
def re_tag_compile(tag):
if type(tag) == type([]):
tag = '(?:' + '|'.join(tag) + ')'
r = "^%s\s*:\s*(\S.*?)\s*$" % tag
return re.compile(r, re.IGNORECASE)
patch_regex = re_tag_compile('Patch(\d*)')
applied_patch_regex = re.compile("^%patch(\d*)")
applied_patch_p_regex = re.compile("\s-P\s+(\d+)\\b")
@ -110,12 +109,14 @@ tarball_regex = re.compile('\.(?:t(?:ar|[glx]z|bz2?)|zip)\\b', re.IGNORECASE)
UNICODE_NBSP = unicodedata.lookup('NO-BREAK SPACE')
def unversioned(deps):
'''Yield unversioned dependency names from the given list.'''
for dep in deps:
if not dep[1]:
yield dep[0]
def contains_buildroot(line):
'''Check if the given line contains use of rpm buildroot.'''
res = rpm_buildroot_regex.search(line)

View File

@ -440,6 +440,8 @@ for path in ('%perl_archlib', '%perl_vendorarch', '%perl_sitearch',
private_so_paths.add(re.sub(r'/lib(?=/|$)', '/lib64', epath))
_enchant_checkers = {}
def spell_check(pkg, str, fmt, lang, ignored):
dict_found = True
@ -799,7 +801,7 @@ class TagsCheck(AbstractCheck.AbstractCheck):
(scheme, netloc) = urlparse(url)[0:2]
if not scheme or not netloc or "." not in netloc or \
scheme not in ('http', 'https', 'ftp') or \
(Config.getOption('InvalidURL') and \
(Config.getOption('InvalidURL') and
invalid_url_regex.search(url)):
printWarning(pkg, 'invalid-url', tag, url)
else:
@ -867,7 +869,6 @@ class TagsCheck(AbstractCheck.AbstractCheck):
printWarning(pkg, "private-shared-object-provides",
fname, Pkg.formatRequire(*prov))
def check_description(self, pkg, lang, ignored_words):
description = pkg.langtag(rpm.RPMTAG_DESCRIPTION, lang)
self._unexpanded_macros(pkg, '%%description -l %s' % lang, description)

View File

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
#------------------------------------------------------------------------------
#############################################################################
# File : ZipCheck.py
# Package : rpmlint
# Author : Ville Skyttä
# Created on : Thu Oct 30 00:14:45 EET 2003
# Purpose : Verify Zip/Jar file correctness
#------------------------------------------------------------------------------
#############################################################################
import os
import re
@ -24,6 +24,7 @@ classpath_regex = re.compile('^\s*Class-Path\s*:', re.M | re.I)
want_indexed_jars = Config.getOption('UseIndexedJars', True)
class ZipCheck(AbstractCheck.AbstractCheck):
def __init__(self):

10
rpmlint
View File

@ -39,6 +39,7 @@ import Pkg
_default_user_conf = '%s/rpmlint' % \
(os.environ.get('XDG_CONFIG_HOME') or '~/.config')
# Print usage information
def usage(name):
print ('''usage: %s [<options>] <rpm files|installed packages|specfiles|dirs>
@ -55,13 +56,15 @@ def usage(name):
\t[-n|--noexception]
\t[ --rawout <file>]
\t[-f|--file <user config file to use instead of %s]
\t[-o|--option <key value>]''' \
\t[-o|--option <key value>]'''
% (name, _default_user_conf))
# Print version information
def printVersion():
print ('rpmlint version %s Copyright (C) 1999-2007 Frederic Lepied, Mandriva' % Config.__version__)
def loadCheck(name):
'''Load a (check) module by its name, unless it is already loaded.'''
# Avoid loading more than once (initialization costs)
@ -74,6 +77,7 @@ def loadCheck(name):
finally:
fobj.close()
#############################################################################
# main program
#############################################################################
@ -194,7 +198,7 @@ def main():
sys.exit(66)
finally:
print("%d packages and %d specfiles checked; %d errors, %d warnings." \
print("%d packages and %d specfiles checked; %d errors, %d warnings."
% (packages_checked, specfiles_checked,
printed_messages["E"], printed_messages["W"]))
@ -202,6 +206,7 @@ def main():
sys.exit(64)
sys.exit(0)
def runChecks(pkg):
try:
@ -218,6 +223,7 @@ def runChecks(pkg):
finally:
pkg.cleanup()
def runSpecChecks(pkg, fname):
try:

View File

@ -10,27 +10,33 @@ import Pkg
currently_testing = 0
output = []
def isTest():
return currently_testing
def startTest():
global currently_testing
global output
output = []
currently_testing = 1
def addOutput(s):
global output
output.append(s)
def getOutput():
global output
return output
def getTestedPackage(name):
pkg_path = glob.glob(os.environ['TESTPATH'] + '/' + name + '-*.rpm')[0]
return Pkg.Pkg(pkg_path, tempfile.gettempdir())
def getTestedSpecPackage(name):
pkg_path = glob.glob(os.environ['TESTPATH'] + '/' + name + '.spec')[0]
return Pkg.FakePkg(pkg_path)

View File

@ -38,11 +38,11 @@ print ""
print "LANGUAGES = set(("
for code in sorted(langs):
if code:
print "\t\"%s\"," % code
print " \"%s\"," % code
print "))"
print ""
print "COUNTRIES = set(("
for code in sorted(countries):
if code:
print "\t\"%s\"," % code
print " \"%s\"," % code
print "))"