aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-06-30 14:38:26 +0200
committerGuido Günther <agx@sigxcpu.org>2016-06-30 16:45:22 +0200
commit6732732d3336d067bcaf140862158c56b62b8031 (patch)
treeb362b5e1cb0993ecf26a6d9e195bc20d56baebb5
parentc5cfb5ecc4c0fab706a5fb984ebf60dfa34390f2 (diff)
rpm-ch: Make pylint happy
-rw-r--r--gbp/rpm/changelog.py7
-rw-r--r--gbp/rpm/policy.py15
-rw-r--r--tests/component/rpm/test_rpm_ch.py8
-rw-r--r--tests/test_rpm_changelog.py4
4 files changed, 15 insertions, 19 deletions
diff --git a/gbp/rpm/changelog.py b/gbp/rpm/changelog.py
index 3ed89f1..504391a 100644
--- a/gbp/rpm/changelog.py
+++ b/gbp/rpm/changelog.py
@@ -46,7 +46,7 @@ class _ChangelogHeader(object):
def __str__(self):
keys = dict(self._data)
keys['time'] = self._data['time'].strftime(
- self._pkgpolicy.Changelog.header_time_format)
+ self._pkgpolicy.Changelog.header_time_format)
try:
return self._pkgpolicy.Changelog.header_format % keys + '\n'
except KeyError as err:
@@ -93,7 +93,6 @@ class _ChangelogSection(object):
self.entries = []
self._trailer = '\n'
-
def __str__(self):
text = str(self.header)
for entry in self.entries:
@@ -180,7 +179,7 @@ class ChangelogParser(object):
raise ChangelogError("Unable to parse changelog header: %s" % text)
try:
time = datetime.datetime.strptime(match.group('ch_time'),
- "%a %b %d %Y")
+ "%a %b %d %Y")
except ValueError:
raise ChangelogError("Unable to parse changelog header: invalid "
"timestamp '%s'" % match.group('ch_time'))
@@ -225,7 +224,6 @@ class ChangelogParser(object):
return entries
-
def parse_section(self, text):
"""Parse one section"""
# Check that the first line(s) look like a changelog header
@@ -243,4 +241,3 @@ class ChangelogParser(object):
section.append_entry(entry)
return section
-
diff --git a/gbp/rpm/policy.py b/gbp/rpm/policy.py
index 0b389f4..b1b1337 100644
--- a/gbp/rpm/policy.py
+++ b/gbp/rpm/policy.py
@@ -21,6 +21,7 @@ import re
from gbp.pkg import PkgPolicy, parse_archive_filename
from gbp.scripts.common.pq import parse_gbp_commands
+
class RpmPkgPolicy(PkgPolicy):
"""Packaging policy for RPM"""
@@ -35,15 +36,15 @@ class RpmPkgPolicy(PkgPolicy):
# Regexp for checking the validity of package name
packagename_re = re.compile("^[%s][%s%s]+$" %
- (alnum, alnum, name_whitelist_chars))
+ (alnum, alnum, name_whitelist_chars))
packagename_msg = ("Package names must be at least two characters long, "
"start with an alphanumeric and can only contain "
"alphanumerics or characters in %s" %
- list(name_whitelist_chars))
+ list(name_whitelist_chars))
# Regexp for checking the validity of package (upstream) version
upstreamversion_re = re.compile("^[0-9][%s%s]*$" %
- (alnum, version_whitelist_chars))
+ (alnum, version_whitelist_chars))
upstreamversion_msg = ("Upstream version numbers must start with a digit "
"and can only containg alphanumerics or characters "
"in %s" % list(version_whitelist_chars))
@@ -77,7 +78,7 @@ class RpmPkgPolicy(PkgPolicy):
# Regexps for splitting/parsing the changelog section (of
# Tizen / Fedora style changelogs)
- section_match_re = r'^\*'
+ section_match_re = r'^\*'
section_split_re = r'^\*\s*(?P<ch_header>\S.*?)$\n(?P<ch_body>.*)'
header_split_re = r'(?P<ch_time>\S.*\s[0-9]{4})\s+(?P<ch_name>\S.*$)'
header_name_split_re = r'(?P<name>[^<]*)\s+<(?P<email>[^>]+)>((\s*-)?\s+(?P<revision>\S+))?$'
@@ -88,7 +89,6 @@ class RpmPkgPolicy(PkgPolicy):
header_time_format = "%a %b %d %Y"
header_rev_format = "%(version)s"
-
class ChangelogEntryFormatter(object):
"""Helper class for generating changelog entries from git commits"""
@@ -123,7 +123,7 @@ class RpmPkgPolicy(PkgPolicy):
tag = match.group('tag')
ids_str = match.group('ids')
bug_ids = [bug_id.strip() for bug_id in
- bug_id_re.findall(ids_str)]
+ bug_id_re.findall(ids_str)]
if tag in tags:
tags[tag] += bug_ids
else:
@@ -186,7 +186,7 @@ class RpmPkgPolicy(PkgPolicy):
text = ["- %s" % subject]
# Add all non-filtered-out lines from commit message, unless 'short'
- if (kwargs['full'] or 'full' in cmds) and not 'short' in cmds:
+ if (kwargs['full'] or 'full' in cmds) and 'short' not in cmds:
# Add all non-blank body lines.
text.extend([" " + line for line in body if line.strip()])
@@ -198,4 +198,3 @@ class RpmPkgPolicy(PkgPolicy):
text[-1] += bts_msg
return text
-
diff --git a/tests/component/rpm/test_rpm_ch.py b/tests/component/rpm/test_rpm_ch.py
index 44507c4..b55c669 100644
--- a/tests/component/rpm/test_rpm_ch.py
+++ b/tests/component/rpm/test_rpm_ch.py
@@ -18,7 +18,7 @@
import os
import re
-from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611
+from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611
from gbp.scripts.rpm_ch import main as rpm_ch
from gbp.git import GitRepository
@@ -35,6 +35,7 @@ def mock_ch(args):
return rpm_ch(['arg0', '--packaging-branch=master',
'--spawn-editor=never'] + args)
+
class TestRpmCh(RpmRepoTestBase):
"""Basic tests for git-rpm-ch"""
@@ -227,7 +228,7 @@ class TestRpmCh(RpmRepoTestBase):
'Signed-off-by:.*']), 0)
commit_msg_body = repo.get_commit_info('HEAD')['body']
full_msg = [line for line in commit_msg_body.splitlines() if
- (line and not line.startswith('Signed-off-by:'))]
+ (line and not line.startswith('Signed-off-by:'))]
content = self.read_file('packaging/gbp-test-native.changes')
# New lines: header, 1 entry "header", filtered entry "body" from
# commit message and one empty line
@@ -326,7 +327,7 @@ class TestRpmCh(RpmRepoTestBase):
def test_commit_guessing_fail(self):
"""Test for failure of start commit guessing"""
- repo = self.init_test_repo('gbp-test-native')
+ self.init_test_repo('gbp-test-native')
# Add "very old" header to changelog
with open('packaging/gbp-test-native.changes', 'w') as ch_fp:
@@ -335,4 +336,3 @@ class TestRpmCh(RpmRepoTestBase):
# last changelog section
eq_(mock_ch([]), 1)
self._check_log(-1, "gbp:error: Couldn't determine starting point")
-
diff --git a/tests/test_rpm_changelog.py b/tests/test_rpm_changelog.py
index b31824a..3e74804 100644
--- a/tests/test_rpm_changelog.py
+++ b/tests/test_rpm_changelog.py
@@ -33,7 +33,7 @@ class TestChangelogHeader(object):
"""Basic test for header"""
time = datetime(2014, 01, 29, 12, 13, 14)
header = _ChangelogHeader(RpmPkgPolicy, time, name="John Doe",
- email="user@host.com", revision="1")
+ email="user@host.com", revision="1")
eq_(str(header), "* Wed Jan 29 2014 John Doe <user@host.com> 1\n")
def test_str_format_err(self):
@@ -91,7 +91,6 @@ class TestChangelogSection(object):
"- another\n change\n\n")
eq_(new_entry, section.entries[-1])
-
def test_set_header(self):
"""Test set_header() method"""
section = self.default_sect
@@ -99,6 +98,7 @@ class TestChangelogSection(object):
section.set_header(time=time, name="Jane", email="u@h", revision="1.1")
eq_(str(section), "* Thu Jan 30 2014 Jane <u@h> 1.1\n- my change\n\n")
+
class TestChangelogParser(object):
"""Test the default changelog parser"""