From: Zhang Qiang Date: Fri, 8 Feb 2013 06:09:26 +0000 (+0800) Subject: CentOS compatibility: make GBP work with older python2.6 X-Git-Tag: tizen/0.6.22-20150206~84 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26cb11e290389d5611ada756dadfcd468f0866ea;p=tools%2Fgit-buildpackage.git CentOS compatibility: make GBP work with older python2.6 - use loops to generate dict/list - Called logging.Logger.__init__ instead of using super(). In python 2.6 logging.Logger is not new-style class, therefore supper() is failing. Signed-off-by: Ed Bartosh Signed-off-by: Zhang Qiang Signed-off-by: Markus Lehtonen --- diff --git a/gbp/log.py b/gbp/log.py index 3db4f5b..17cd680 100644 --- a/gbp/log.py +++ b/gbp/log.py @@ -54,7 +54,7 @@ class GbpStreamHandler(logging.StreamHandler): OFF_SEQ = "\033[0m" def __init__(self, stream=None, color='auto'): - super(GbpStreamHandler, self).__init__(stream) + logging.StreamHandler.__init__(self, stream) self._color = gbp.tristate.Tristate(color) self._color_scheme = DEFAULT_COLOR_SCHEME.copy() msg_fmt = "%(color)s%(name)s:%(levelname)s: %(message)s%(coloroff)s" @@ -90,14 +90,14 @@ class GbpStreamHandler(logging.StreamHandler): record.color = self.COLOR_SEQ % self._color_scheme[record.levelno] record.coloroff = self.OFF_SEQ record.levelname = record.levelname.lower() - return super(GbpStreamHandler, self).format(record) + return logging.StreamHandler.format(self, record) class GbpLogger(logging.Logger): """Logger class for git-buildpackage""" def __init__(self, name, color='auto', *args, **kwargs): - super(GbpLogger, self).__init__(name, *args, **kwargs) + logging.Logger.__init__(self, name, *args, **kwargs) self._default_handlers = [GbpStreamHandler(sys.stdout, color), GbpStreamHandler(sys.stderr, color)] self._default_handlers[0].addFilter(GbpFilter([DEBUG, INFO])) diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py index 87f82ff..f6c0d59 100644 --- a/gbp/rpm/__init__.py +++ b/gbp/rpm/__init__.py @@ -224,20 +224,28 @@ class SpecFile(object): def _patches(self): """Get all patch tags as a dict""" + patches = {} if 'patch' not in self._tags: return {} - return {patch['num']: patch for patch in self._tags['patch']['lines']} + for patch in self._tags['patch']['lines']: + patches[patch['num']] = patch + return patches def _sources(self): """Get all source tags as a dict""" + sources = {} if 'source' not in self._tags: return {} - return {src['num']: src for src in self._tags['source']['lines']} + for src in self._tags['source']['lines']: + sources[src['num']] = src + return sources def sources(self): """Get all source tags as a dict""" - return {src['num']: src['linevalue'] - for src in self._sources().values()} + sources = {} + for src in self._sources().values(): + sources[src['num']] = src['linevalue'] + return sources def _macro_replace(self, matchobj): macro_dict = {'name': self.name,