- remove pychecker errors:
- unused variable - variable that shadow builtins - unused expression ( usually used to trigger a exception ) - do not raise string as exception git-svn-id: svn+ssh://rpmlint.zarb.org/home/projects/rpmlint/svn/trunk@1204 9bc8b190-ac0f-0410-8968-dc7d1f502856
This commit is contained in:
parent
147e2b2c4c
commit
e3fd820a6f
|
@ -27,7 +27,6 @@ class AbstractFilesCheck(AbstractCheck):
|
|||
def check(self, pkg):
|
||||
if pkg.isSource():
|
||||
return
|
||||
dirname = pkg.dirName()
|
||||
files = []
|
||||
for f in pkg.files().keys():
|
||||
if self.__files_re.match(f):
|
||||
|
|
|
@ -186,9 +186,9 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
|
|||
if not validso_regex.search(bin_info.soname):
|
||||
printError(pkg, 'invalid-soname', i[0], bin_info.soname)
|
||||
else:
|
||||
(dir, base) = dir_base(i[0])
|
||||
(directory, base) = dir_base(i[0])
|
||||
try:
|
||||
symlink = dir + bin_info.soname
|
||||
symlink = directory + bin_info.soname
|
||||
(perm, owner, group, link, size, md5, mtime, rdev) = files[symlink]
|
||||
if link != i[0] and link != base and link != '':
|
||||
printError(pkg, 'invalid-ldconfig-symlink', i[0], link)
|
||||
|
|
|
@ -77,10 +77,10 @@ _dirs=["/usr/share/rpmlint"]
|
|||
def addCheckDir(dir):
|
||||
global _dirs
|
||||
|
||||
dir=os.path.expanduser(dir)
|
||||
d = os.path.expanduser(dir)
|
||||
|
||||
if not dir in _dirs:
|
||||
_dirs.insert(0, dir)
|
||||
if not d in _dirs:
|
||||
_dirs.insert(0, d)
|
||||
|
||||
def checkDirs():
|
||||
global _dirs
|
||||
|
|
|
@ -35,7 +35,7 @@ class DocFilesCheck(AbstractCheck.AbstractCheck):
|
|||
def __init__(self):
|
||||
AbstractCheck.AbstractCheck.__init__(self, 'DocFilesCheck')
|
||||
|
||||
def __checkRequirements(this, pkg):
|
||||
def __checkRequirements(self, pkg):
|
||||
file_reqs = pkg.header[rpm.RPMTAG_FILEREQUIRE]
|
||||
files = pkg.header[rpm.RPMTAG_FILENAMES] # not files().keys()!
|
||||
doc_files = pkg.docFiles()
|
||||
|
@ -81,9 +81,7 @@ class DocFilesCheck(AbstractCheck.AbstractCheck):
|
|||
def check(self, pkg):
|
||||
if pkg.isSource():
|
||||
return
|
||||
try:
|
||||
foo = rpm.RPMTAG_FILEREQUIRE # need rpm >= 4.1.1
|
||||
except:
|
||||
if not 'RPMTAG_FILEREQUIRE' in dir(rpm): # need rpm >= 4.1.1
|
||||
return
|
||||
|
||||
self.__checkRequirements(pkg)
|
||||
|
|
26
FHSCheck.py
26
FHSCheck.py
|
@ -33,23 +33,23 @@ class FHSCheck(AbstractCheck.AbstractCheck):
|
|||
for f in files.keys():
|
||||
s=FHSCheck.usr_regex.search(f)
|
||||
if s:
|
||||
dir=s.group(1)
|
||||
if not FHSCheck.usr_subdir_regex.search(dir):
|
||||
if not dir in usr_list:
|
||||
printWarning(pkg, "non-standard-dir-in-usr", dir)
|
||||
usr_list.append(dir)
|
||||
d = s.group(1)
|
||||
if not FHSCheck.usr_subdir_regex.search(d):
|
||||
if not d in usr_list:
|
||||
printWarning(pkg, "non-standard-dir-in-usr", d)
|
||||
usr_list.append(d)
|
||||
else:
|
||||
s=FHSCheck.var_regex.search(f)
|
||||
if s:
|
||||
dir=s.group(1)
|
||||
if FHSCheck.var_fsstnd_regex.search(dir):
|
||||
if not dir in var_list:
|
||||
d = s.group(1)
|
||||
if FHSCheck.var_fsstnd_regex.search(d):
|
||||
if not d in var_list:
|
||||
printWarning(pkg, "FSSTND-dir-in-var", f)
|
||||
var_list.append(dir)
|
||||
elif not FHSCheck.var_subdir_regex.search(dir):
|
||||
if not dir in var_list:
|
||||
printWarning(pkg, "non-standard-dir-in-var", dir)
|
||||
var_list.append(dir)
|
||||
var_list.append(d)
|
||||
elif not FHSCheck.var_subdir_regex.search(d):
|
||||
if not d in var_list:
|
||||
printWarning(pkg, "non-standard-dir-in-var", d)
|
||||
var_list.append(d)
|
||||
|
||||
# Create an object to enable the auto registration of the test
|
||||
check=FHSCheck()
|
||||
|
|
|
@ -61,12 +61,12 @@ CORRECT_SUBDIRS = (
|
|||
'zh_CN.GB2312', 'zh_TW.Big5',
|
||||
)
|
||||
|
||||
str='-('
|
||||
st = '-('
|
||||
for s in CORRECT_SUBDIRS:
|
||||
str=str+'|'+s[0:2]
|
||||
str=str+')$'
|
||||
st += '|' + s[0:2]
|
||||
st += ')$'
|
||||
|
||||
package_regex=re.compile(str)
|
||||
package_regex=re.compile(st)
|
||||
locale_regex=re.compile('^(/usr/share/locale/([^/]+))/')
|
||||
correct_subdir_regex=re.compile('^(([a-z][a-z](_[A-Z][A-Z])?)([.@].*$)?)$')
|
||||
lc_messages_regex=re.compile('/usr/share/locale/([^/]+)/LC_MESSAGES/.*(mo|po)$')
|
||||
|
|
|
@ -326,9 +326,7 @@ class MenuCheck(AbstractCheck.AbstractCheck):
|
|||
printWarning(pkg, 'hardcoded-path-in-menu-icon', icon)
|
||||
else:
|
||||
for path in icon_paths:
|
||||
try:
|
||||
files[path[0] + icon]
|
||||
except KeyError:
|
||||
if not (path[0] + icon) in files.keys():
|
||||
printError(pkg, path[1] + '-icon-not-in-package', icon, f)
|
||||
else:
|
||||
printWarning(pkg, 'no-icon-in-menu', title)
|
||||
|
|
|
@ -28,6 +28,9 @@ import Config
|
|||
executable_re=re.compile('^(/usr)?/(s?bin|games)/\S+')
|
||||
simple_naming_policy_re=re.compile('\^[a-zA-Z1-9-_]*$');
|
||||
|
||||
class NamingPolicyNotAppliedException(Exception):
|
||||
pass
|
||||
|
||||
class NamingPolicyCheck(AbstractCheck.AbstractCheck):
|
||||
checks_=[]
|
||||
|
||||
|
@ -54,13 +57,13 @@ class NamingPolicyCheck(AbstractCheck.AbstractCheck):
|
|||
def check(self, pkg):
|
||||
if pkg.isSource():
|
||||
return
|
||||
list = pkg.files().keys()
|
||||
if not list:
|
||||
files = pkg.files().keys()
|
||||
if not files:
|
||||
return
|
||||
try:
|
||||
# check for binaries first
|
||||
executables=0
|
||||
for f in list:
|
||||
for f in files:
|
||||
if executable_re.search(f):
|
||||
executables=1
|
||||
break
|
||||
|
@ -71,10 +74,10 @@ class NamingPolicyCheck(AbstractCheck.AbstractCheck):
|
|||
if c['exception'] and executables:
|
||||
exception=1
|
||||
|
||||
for f in list:
|
||||
for f in files:
|
||||
if c['file_re'].search(f) and not c['name_re'].search(pkg.name) and not exception:
|
||||
raise 'naming-policy-not-applied'
|
||||
except 'naming-policy-not-applied':
|
||||
raise NamingPolicyNotAppliedException
|
||||
except NamingPolicyNotAppliedException:
|
||||
printWarning(pkg, c['pkg_name'] + '-naming-policy-not-applied', f)
|
||||
|
||||
check=NamingPolicyCheck()
|
||||
|
|
13
PostCheck.py
13
PostCheck.py
|
@ -58,9 +58,9 @@ def incorrect_shell_script(prog, shellscript):
|
|||
if not shellscript:
|
||||
return 0
|
||||
# TODO: test that "prog" is available/executable
|
||||
file=open(tmpfile, 'w')
|
||||
file.write(shellscript)
|
||||
file.close()
|
||||
f = open(tmpfile, 'w')
|
||||
f.write(shellscript)
|
||||
f.close()
|
||||
ret=commands.getstatusoutput('%s -n %s' % (prog, tmpfile))
|
||||
os.remove(tmpfile)
|
||||
return ret[0]
|
||||
|
@ -70,9 +70,9 @@ def incorrect_perl_script(prog, perlscript):
|
|||
if not perlscript:
|
||||
return 0
|
||||
# TODO: test that "prog" is available/executable
|
||||
file=open(tmpfile, 'w')
|
||||
file.write(perlscript)
|
||||
file.close()
|
||||
f = open(tmpfile, 'w')
|
||||
f.write(perlscript)
|
||||
f.close()
|
||||
ret=commands.getstatusoutput('%s -wc %s' % (prog, tmpfile))
|
||||
os.remove(tmpfile)
|
||||
return ret[0]
|
||||
|
@ -87,7 +87,6 @@ class PostCheck(AbstractCheck.AbstractCheck):
|
|||
if pkg.isSource():
|
||||
return
|
||||
|
||||
menu_error=0
|
||||
prereq=map(lambda x: x[0], pkg.prereq())
|
||||
files=pkg.files().keys()
|
||||
|
||||
|
|
14
ZipCheck.py
14
ZipCheck.py
|
@ -32,14 +32,14 @@ class ZipCheck(AbstractCheck.AbstractCheck):
|
|||
if zip_regex.search(f) and \
|
||||
stat.S_ISREG(os.lstat(f)[stat.ST_MODE]) and \
|
||||
zipfile.is_zipfile(f):
|
||||
zip = None
|
||||
z = None
|
||||
try:
|
||||
zip = zipfile.ZipFile(f, 'r')
|
||||
badcrc = zip.testzip()
|
||||
z = zipfile.ZipFile(f, 'r')
|
||||
badcrc = z.testzip()
|
||||
if badcrc:
|
||||
printError(pkg, 'bad-crc-in-zip: %s' % badcrc, i[0])
|
||||
compressed = 0
|
||||
for zinfo in zip.infolist():
|
||||
for zinfo in z.infolist():
|
||||
if zinfo.compress_type != zipfile.ZIP_STORED:
|
||||
compressed = 1
|
||||
break
|
||||
|
@ -49,13 +49,13 @@ class ZipCheck(AbstractCheck.AbstractCheck):
|
|||
# additional jar checks
|
||||
if jar_regex.search(f):
|
||||
try:
|
||||
mf = zip.read('META-INF/MANIFEST.MF')
|
||||
mf = z.read('META-INF/MANIFEST.MF')
|
||||
if classpath_regex.search(mf):
|
||||
printWarning(pkg, 'class-path-in-manifest', i[0])
|
||||
except KeyError:
|
||||
printError(pkg, 'no-jar-manifest', i[0])
|
||||
try:
|
||||
zinfo = zip.getinfo('META-INF/INDEX.LIST')
|
||||
zinfo = z.getinfo('META-INF/INDEX.LIST')
|
||||
if not want_indexed_jars:
|
||||
printWarning(pkg, 'jar-indexed', i[0])
|
||||
except KeyError:
|
||||
|
@ -65,7 +65,7 @@ class ZipCheck(AbstractCheck.AbstractCheck):
|
|||
except:
|
||||
sys.stderr.write('%s: unable-to-read-zip %s "%s"\n' % (pkg.name, i[0], sys.exc_info()[1]))
|
||||
|
||||
zip and zip.close()
|
||||
z and z.close()
|
||||
|
||||
|
||||
check = ZipCheck()
|
||||
|
|
Loading…
Reference in New Issue