Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config_overrides = {}
# process command line options
for o in opt:
if o[0] in ('-c', '--check'):
checks.append(o[1])
elif o[0] in ('-i', '--info'):
Config.info = True
elif o[0] in ('-I', '--explain'):
# split by comma for deprecated backwards compatibility with < 1.2
info_error.update(o[1].split(','))
elif o[0] in ('-h', '--help'):
usage(argv0)
sys.exit(0)
elif o[0] in ('-C', '--checkdir'):
Config.addCheckDir(o[1])
elif o[0] in ('-v', '--verbose'):
verbose = True
elif o[0] in ('-V', '--version'):
printVersion()
sys.exit(0)
elif o[0] in ('-E', '--extractdir'):
extract_dir = o[1]
Config.setOption('ExtractDir', extract_dir)
elif o[0] in ('-n', '--noexception'):
Config.no_exception = True
elif o[0] in ('-a', '--all'):
if '*' not in args:
args.append('*')
elif o[0] in ('-f', '--file'):
conf_file = o[1]
elif o[0] in ('-o', '--option'):
exec(compile(fobj.read(), expconf, 'exec'))
except IOError:
pass
except Exception as e:
Pkg.warn('(none): W: error loading %s, skipping: %s' % (conf_file, e))
# apply config overrides
for key, value in config_overrides.items():
Config.setOption(key, value)
if not extract_dir:
extract_dir = Config.getOption('ExtractDir', tempfile.gettempdir())
if info_error:
Config.info = True
sys.path[0:0] = Config.checkDirs()
for c in checks:
Config.addCheck(c)
for c in Config.allChecks():
loadCheck(c)
for e in sorted(info_error):
print("%s:" % e)
printDescriptions(e)
sys.exit(0)
# if no argument print usage
if not args:
usage(argv0)
sys.exit(1)
if __name__ == '__main__':
if checks:
Config.addCheck(c)
for c in Config.allChecks():
loadCheck(c)
for e in sorted(info_error):
print("%s:" % e)
printDescriptions(e)
sys.exit(0)
# if no argument print usage
if not args:
usage(argv0)
sys.exit(1)
if __name__ == '__main__':
if checks:
Config.resetChecks()
for check in checks:
Config.addCheck(check)
main()
info_error.update(o[1].split(','))
elif o[0] in ('-h', '--help'):
usage(argv0)
sys.exit(0)
elif o[0] in ('-C', '--checkdir'):
Config.addCheckDir(o[1])
elif o[0] in ('-v', '--verbose'):
verbose = True
elif o[0] in ('-V', '--version'):
printVersion()
sys.exit(0)
elif o[0] in ('-E', '--extractdir'):
extract_dir = o[1]
Config.setOption('ExtractDir', extract_dir)
elif o[0] in ('-n', '--noexception'):
Config.no_exception = True
elif o[0] in ('-a', '--all'):
if '*' not in args:
args.append('*')
elif o[0] in ('-f', '--file'):
conf_file = o[1]
elif o[0] in ('-o', '--option'):
kv = o[1].split(None, 1)
if len(kv) == 1:
config_overrides[kv[0]] = None
else:
config_overrides[kv[0]] = eval(kv[1])
elif o[0] in ('--rawout',):
setRawOut(o[1])
# load user config file
try:
elif o[0] in ('-I', '--explain'):
# split by comma for deprecated backwards compatibility with < 1.2
info_error.update(o[1].split(','))
elif o[0] in ('-h', '--help'):
usage(argv0)
sys.exit(0)
elif o[0] in ('-C', '--checkdir'):
Config.addCheckDir(o[1])
elif o[0] in ('-v', '--verbose'):
verbose = True
elif o[0] in ('-V', '--version'):
printVersion()
sys.exit(0)
elif o[0] in ('-E', '--extractdir'):
extract_dir = o[1]
Config.setOption('ExtractDir', extract_dir)
elif o[0] in ('-n', '--noexception'):
Config.no_exception = True
elif o[0] in ('-a', '--all'):
if '*' not in args:
args.append('*')
elif o[0] in ('-f', '--file'):
conf_file = o[1]
elif o[0] in ('-o', '--option'):
kv = o[1].split(None, 1)
if len(kv) == 1:
config_overrides[kv[0]] = None
else:
config_overrides[kv[0]] = eval(kv[1])
elif o[0] in ('--rawout',):
setRawOut(o[1])
with open(expconf) as fobj:
exec(compile(fobj.read(), expconf, 'exec'))
except IOError:
pass
except Exception as e:
Pkg.warn('(none): W: error loading %s, skipping: %s' % (conf_file, e))
# apply config overrides
for key, value in config_overrides.items():
Config.setOption(key, value)
if not extract_dir:
extract_dir = Config.getOption('ExtractDir', tempfile.gettempdir())
if info_error:
Config.info = True
sys.path[0:0] = Config.checkDirs()
for c in checks:
Config.addCheck(c)
for c in Config.allChecks():
loadCheck(c)
for e in sorted(info_error):
print("%s:" % e)
printDescriptions(e)
sys.exit(0)
# if no argument print usage
if not args:
usage(argv0)
sys.exit(1)
if __name__ == '__main__':
def printVersion():
print('rpmlint version %s' % Config.__version__)