def __init__(self, config):
self.classification_data = None
self.classification_path = config.get(
"pkglint", "info_classification_path")
self.skip_classification_check = False
# a default error message used if we've parsed the
# data file, but haven't thrown any exceptions
self.bad_classification_data = _("no sections found in data "
"file {0}").format(self.classification_path)
if os.path.exists(self.classification_path):
try:
if six.PY2:
self.classification_data = \
configparser.SafeConfigParser()
self.classification_data.readfp(
open(self.classification_path))
else:
# SafeConfigParser has been renamed to
# ConfigParser in Python 3.2.
self.classification_data = \
configparser.ConfigParser()
self.classification_data.read_file(
open(self.classification_path))
except Exception as err:
# any exception thrown here results in a null
# classification_data object. We deal with that
# later.
self.bad_classification_data = _(
"unable to parse data file {path}: "
"{err}").format(
path=self.classification_path,
err=err)
pass
else:
self.bad_classification_data = _("missing file {0}").format(
self.classification_path)
super(ManifestChecker, self).__init__(config)
评论列表
文章目录