/usr/share/rpmlint/Config.py is in rpmlint 1.9-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | # -*- coding: utf-8 -*-
#############################################################################
# File : Config.py
# Package : rpmlint
# Author : Frederic Lepied
# Created on : Fri Oct 15 20:04:25 1999
# Purpose : handle configuration options. To be used from config files.
#############################################################################
import locale
import os.path
import re
try:
from __version__ import __version__
except ImportError:
__version__ = 'devel'
DEFAULT_CHECKS = ("DistributionCheck",
"TagsCheck",
"BinariesCheck",
"ConfigCheck",
"FilesCheck",
"DocFilesCheck",
"FHSCheck",
"SignatureCheck",
"I18NCheck",
"MenuCheck",
"PostCheck",
"InitScriptCheck",
"SourceCheck",
"SpecCheck",
"NamingPolicyCheck",
"ZipCheck",
"PamCheck",
"RpmFileCheck",
"MenuXDGCheck",
"AppDataCheck",
)
USEUTF8_DEFAULT = False
try:
if locale.getpreferredencoding() == 'UTF-8':
USEUTF8_DEFAULT = True
except:
try:
if re.match('utf', locale.getdefaultlocale()[1], re.I):
USEUTF8_DEFAULT = True
except:
pass
info = False
no_exception = False
# handle the list of checks to load
_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
_checks = []
# handle the list of directories to look for checks
_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
# handle options
_options = {}
def setOption(name, value):
_options[name] = value
def getOption(name, default=""):
try:
return _options[name]
except:
return default
# List of filters
_filters = []
_filters_re = None
def addFilter(s):
global _filters_re
_filters.append(s)
_filters_re = None
def removeFilter(s):
global _filters_re
try:
_filters.remove(s)
except:
pass
else:
_filters_re = None
_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 is None:
# no filter
if len(_filters) == 0:
return False
_filters_re = '(?:' + _filters[0] + ')'
for idx in range(1, len(_filters)):
# to prevent named group overflow that happen when there is too
# many () in a single regexp: AssertionError: sorry, but this
# version only supports 100 named groups
if '(' in _filters[idx]:
_non_named_group_re.subn('(:?', _filters[idx])
_filters_re = _filters_re + '|(?:' + _filters[idx] + ')'
_filters_re = re.compile(_filters_re)
if not no_exception:
if _filters_re.search(s):
return True
return False
# Config.py ends here
# ex: ts=4 sw=4 et
|