Code cleanups.

git-svn-id: svn+ssh://rpmlint.zarb.org/home/projects/rpmlint/svn/trunk@1578 9bc8b190-ac0f-0410-8968-dc7d1f502856
This commit is contained in:
Ville Skyttä 2009-03-23 18:47:03 +00:00
parent 7e9523a7dc
commit 7bbfd9bff6
11 changed files with 33 additions and 34 deletions

View File

@ -374,7 +374,7 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
for f in files:
res = numeric_dir_regex.search(f)
fn = res and res.group(1) or f
if not f in exec_files and not so_regex.search(f) and not versioned_dir_regex.search(fn):
if f not in exec_files and not so_regex.search(f) and not versioned_dir_regex.search(fn):
printError(pkg, 'non-versioned-file-in-library-package', f)
if version and version != -1 and pkg.name.find(version) == -1:
printError(pkg, 'incoherent-version-in-name', version)

View File

@ -56,7 +56,7 @@ def addCheck(check):
global _checks
check = re.sub('\.py[co]?$', '', check)
if not check in _checks:
if check not in _checks:
_checks.append(check)
def allChecks():
@ -84,7 +84,7 @@ def addCheckDir(dir):
d = os.path.expanduser(dir)
if not d in _dirs:
if d not in _dirs:
_dirs.insert(0, d)
def checkDirs():

View File

@ -41,7 +41,7 @@ class ConfigCheck(AbstractCheck.AbstractCheck):
elif not ConfigCheck.etc_var_regex.search(c):
printWarning(pkg, "non-etc-or-var-file-marked-as-conffile", c)
if not c in noreplace_files:
if c not in noreplace_files:
printWarning(pkg, "conffile-without-noreplace-flag", c)
# Create an object to enable the auto registration of the test

View File

@ -38,22 +38,21 @@ class FHSCheck(AbstractCheck.AbstractCheck):
s = FHSCheck.usr_regex.search(fname)
if s:
d = s.group(1)
if not d in FHSCheck.usr_subdir:
if not d in usr_list:
printWarning(pkg, "non-standard-dir-in-usr", d)
usr_list.append(d)
if d not in FHSCheck.usr_subdir and d not in usr_list:
printWarning(pkg, "non-standard-dir-in-usr", d)
usr_list.append(d)
else:
s = FHSCheck.var_regex.search(fname)
if s:
d = s.group(1)
if d in var_list:
continue
if d in FHSCheck.var_fsstnd:
if not d in var_list:
printWarning(pkg, "FSSTND-dir-in-var", fname)
var_list.append(d)
elif not d in FHSCheck.var_subdir:
if not d in var_list:
printWarning(pkg, "non-standard-dir-in-var", d)
var_list.append(d)
printWarning(pkg, "FSSTND-dir-in-var", fname)
var_list.append(d)
elif d not in FHSCheck.var_subdir:
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()

View File

@ -325,9 +325,9 @@ class FilesCheck(AbstractCheck.AbstractCheck):
if mispelled_macro_regex.search(f):
printWarning(pkg, 'mispelled-macro', f)
if standard_users and not user in standard_users:
if standard_users and user not in standard_users:
printWarning(pkg, 'non-standard-uid', f, user)
if standard_groups and not group in standard_groups:
if standard_groups and group not in standard_groups:
printWarning(pkg, 'non-standard-gid', f, group)
if not module_rpms_ok and kernel_modules_regex.search(f) and not is_kernel_package:
@ -430,7 +430,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
printError(pkg, 'non-root-user-log-file', f, user)
if group != 'root':
printError(pkg, 'non-root-group-log-file', f, group)
if not f in ghost_files:
if f not in ghost_files:
printError(pkg, 'non-ghost-file', f)
if doc_regex.search(f):
@ -554,7 +554,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
if nonexec_file:
printWarning(pkg, 'spurious-executable-perm', f)
elif f.startswith('/etc/'):
if not f in config_files and not f in ghost_files:
if f not in config_files and f not in ghost_files:
printWarning(pkg, 'non-conffile-in-etc', f)
if pkg.arch == 'noarch' and f.startswith('/usr/lib64/python'):
@ -581,7 +581,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
# absolute link
r = absolute_regex.search(link)
if r:
if (not is_so) and link not in files and link not in req_names:
if not is_so and link not in files and link not in req_names:
is_exception = 0
for e in dangling_exceptions:
if e[0].search(link):
@ -610,7 +610,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
is_exception = e[1]
break
if is_exception:
if not is_exception in req_names:
if is_exception not in req_names:
printWarning(pkg, 'no-dependency-on', is_exception)
else:
printWarning(pkg, 'dangling-relative-symlink', f, link)

View File

@ -119,11 +119,11 @@ class I18NCheck(AbstractCheck.AbstractCheck):
if res:
locale = res.group(2)
# checks the same locale only once
if not locale in locales:
if locale not in locales:
locales.append(locale)
res2 = correct_subdir_regex.search(locale)
if not res2:
if not locale in EXCEPTION_DIRS:
if locale not in EXCEPTION_DIRS:
printError(pkg, 'incorrect-locale-subdir', f)
else:
locale_name = res2.group(2)
@ -136,13 +136,13 @@ class I18NCheck(AbstractCheck.AbstractCheck):
subdir = None
if res:
subdir = res.group(1)
if not subdir in CORRECT_SUBDIRS:
if subdir not in CORRECT_SUBDIRS:
printError(pkg, 'invalid-lc-messages-dir', f)
else:
res = man_regex.search(f)
if res:
subdir = res.group(1)
if subdir != 'man' and not subdir in CORRECT_SUBDIRS:
if subdir != 'man' and subdir not in CORRECT_SUBDIRS:
printError(pkg, 'invalid-locale-man-dir', f)
else:
subdir = None

View File

@ -254,7 +254,7 @@ class MenuCheck(AbstractCheck.AbstractCheck):
command = command_line[1]
break
if command[0] == '/':
if not command in files:
if command not in files:
printWarning(pkg, 'menu-command-not-in-package', command)
else:
if not ('/bin/' + command in files or
@ -322,7 +322,7 @@ class MenuCheck(AbstractCheck.AbstractCheck):
printWarning(pkg, 'hardcoded-path-in-menu-icon', icon)
else:
for path in icon_paths:
if not (path[0] + icon) in files:
if (path[0] + icon) not in files:
printError(pkg, path[1] + '-icon-not-in-package', icon, f)
else:
printWarning(pkg, 'no-icon-in-menu', title)

4
Pkg.py
View File

@ -161,9 +161,9 @@ def get_default_valid_rpmgroups(filename = ""):
groups = fobj.read().strip().splitlines()
finally:
fobj.close()
if not 'Development/Debug' in groups:
if 'Development/Debug' not in groups:
groups.append('Development/Debug')
groups.sort()
groups.sort()
return groups
# classes representing package

View File

@ -132,13 +132,13 @@ class PostCheck(AbstractCheck.AbstractCheck):
for f in ghost_files:
if (not postin or postin.find(f) == -1) and \
(not prein or prein.find(f) == -1) and \
not f in pkg.missingOkFiles():
f not in pkg.missingOkFiles():
printWarning(pkg, 'postin-without-ghost-file-creation', f)
def check_aux(self, pkg, files, prog, script, tag, prereq):
if script:
if prog:
if not prog in valid_shells:
if prog not in valid_shells:
printError(pkg, 'invalid-shell-in-' + tag[2], prog)
if prog in empty_shells:
printError(pkg, 'non-empty-' + tag[2], prog)

View File

@ -674,7 +674,7 @@ class TagsCheck(AbstractCheck.AbstractCheck):
if pkg.name in obs_names:
printError(pkg, 'obsolete-on-name')
for o in obs_names:
if not o in prov_names:
if o not in prov_names:
printWarning(pkg, 'obsolete-not-provided', o)
for o in pkg.obsoletes():
if o[1].find('%') != -1:

View File

@ -86,10 +86,10 @@ def sense2str(sense):
# compares 2 lists
def cmp_list(o, n, name):
for old in o:
if not old in n:
if old not in n:
print DEPFORMAT % (REMOVED, name, old[0], sense2str(old[2]), old[1])
for new in n:
if not new in o:
if new not in o:
print DEPFORMAT % (ADDED, name, new[0], sense2str(new[2]), new[1])
# filter the own name of the package