Commit 32c52b7f authored by Guido Günther's avatar Guido Günther

Make pylint happy

parent 94bfcca3
# vim: set fileencoding=utf-8 :
#
# (C) 2011 Guido Guenther <agx@sigxcpu.org>
# (C) 2011,2015 Guido Guenther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
......@@ -22,6 +22,7 @@ import subprocess
import tempfile
from gbp.errors import GbpError
class Patch(object):
"""
A patch in a L{PatchSeries}
......@@ -49,7 +50,7 @@ class Patch(object):
repr = "<gbp.patch_series.Patch path='%s' " % self.path
if self.topic:
repr += "topic='%s' " % self.topic
if self.strip != None:
if self.strip is not None:
repr += "strip=%d " % self.strip
repr += ">"
return repr
......@@ -72,7 +73,7 @@ class Patch(object):
header = rfc_header[:-1].lower()
self.info[header] = value.strip()
try:
self.long_desc = "".join([ line for line in body ])
self.long_desc = "".join([line for line in body])
body.close()
except IOError as msg:
raise GbpError("Failed to read patch header of '%s': %s" %
......@@ -127,7 +128,7 @@ class Patch(object):
@param get_val: alternate value if key is not in info dict
@type get_val: C{str}
"""
if self.info == None:
if self.info is None:
self._read_info()
if key in self.info:
......@@ -135,7 +136,6 @@ class Patch(object):
else:
return get_val() if get_val else None
@property
def subject(self):
"""
......@@ -205,7 +205,7 @@ class PatchSeries(list):
queue = PatchSeries()
for line in series:
try:
if line[0] in [ '\n', '#' ]:
if line[0] in ['\n', '#']:
continue
except IndexError:
continue # ignore empty lines
......@@ -223,7 +223,7 @@ class PatchSeries(list):
>>> PatchSeries._get_topic("/asdf")
"""
topic = os.path.dirname(line)
if topic in [ '', '/' ]:
if topic in ['', '/']:
topic = None
return topic
......@@ -265,5 +265,3 @@ class PatchSeries(list):
topic = klass._get_topic(line)
(patch, split) = klass._split_strip(line)
return Patch(os.path.join(patch_dir, patch), topic, split)
......@@ -111,8 +111,6 @@ def parse_gbp_commands(info, cmd_tag, noarg_cmds, arg_cmds, filter_cmds=None):
else:
body.append(line)
msg = '\n'.join(body)
# Add trailing newline if the originial body hat one
#msg += '\n' if info['body'] and info['body'][-1] == '\n' else ''
return (commands, msg)
......@@ -193,7 +191,7 @@ def format_patch(outdir, repo, commit_info, series, numbered=True,
# Make sure that we don't overwrite existing patches in the series
if filepath in series:
presuffix = '-%d' % len(series)
base = base[:base_maxlen-len(presuffix)] + presuffix
base = base[:base_maxlen - len(presuffix)] + presuffix
filename = (num_prefix if numbered else '') + base + suffix
filepath = os.path.join(outdir, filename)
......@@ -281,7 +279,7 @@ def apply_and_commit_patch(repo, patch, fallback_author, topic=None):
"""apply a single patch 'patch', add topic 'topic' and commit it"""
author = {'name': patch.author,
'email': patch.email,
'date': patch.date }
'date': patch.date}
patch_fn = os.path.basename(patch.path)
if not (author['name'] and author['email']):
......
......@@ -26,6 +26,7 @@ from gbp.scripts.pq import generate_patches, export_patches
import gbp.scripts.common.pq as pq
import gbp.patch_series
class TestApplyAndCommit(testutils.DebianGitTestRepo):
"""Test L{gbp.pq}'s apply_and_commit"""
......@@ -40,7 +41,6 @@ class TestApplyAndCommit(testutils.DebianGitTestRepo):
pq.apply_and_commit_patch(self.repo, patch, None)
self.assertIn('foo', self.repo.list_files())
def test_topic(self):
"""Test if setting a topic works"""
patch = gbp.patch_series.Patch(_patch_path('foo.patch'))
......@@ -79,6 +79,7 @@ class TestApplyAndCommit(testutils.DebianGitTestRepo):
self.assertEqual(info['author'].email, 'gg@godiug.net')
self.assertIn('foo', self.repo.list_files())
class TestApplySinglePatch(testutils.DebianGitTestRepo):
"""Test L{gbp.pq}'s apply_single_patch"""
......@@ -94,6 +95,7 @@ class TestApplySinglePatch(testutils.DebianGitTestRepo):
pq.apply_single_patch(self.repo, 'master', patch, None)
self.assertIn('foo', self.repo.list_files())
class TestWritePatch(testutils.DebianGitTestRepo):
"""Test L{gbp.pq}'s write_patch """
......@@ -107,7 +109,8 @@ class TestWritePatch(testutils.DebianGitTestRepo):
def test_generate_patches(self):
"""Test generation of patches"""
class opts: patch_numbers = False
class opts:
patch_numbers = False
# Add test file with topic:
msg = ("added foo\n\n"
......@@ -134,6 +137,7 @@ class TestWritePatch(testutils.DebianGitTestRepo):
# Branches must be identical afterwards
self.assertEqual('', diff)
class TestExport(testutils.DebianGitTestRepo):
class Options(object):
drop = True
......@@ -158,7 +162,7 @@ class TestExport(testutils.DebianGitTestRepo):
class TestParseGbpCommand(unittest.TestCase):
def test_empty_body(self):
"""Test command filtering with an empty body"""
info = { 'body': '' }
info = {'body': ''}
(cmds, body) = pq.parse_gbp_commands(info, ['tag'], ['cmd1'], ['cmd2'])
self.assertEquals(cmds, {})
self.assertEquals(body, '')
......@@ -166,7 +170,7 @@ class TestParseGbpCommand(unittest.TestCase):
def test_noarg_cmd(self):
orig_body = '\n'.join(["Foo",
"tag: cmd1"])
info = { 'body': orig_body }
info = {'body': orig_body}
(cmds, body) = pq.parse_gbp_commands(info, 'tag', ['cmd'], ['argcmd'])
self.assertEquals(cmds, {'cmd': None})
self.assertEquals(body, orig_body)
......@@ -174,7 +178,7 @@ class TestParseGbpCommand(unittest.TestCase):
def test_filter_cmd(self):
orig_body = '\n'.join(["Foo",
"tag: cmd1"])
info = { 'body': orig_body }
info = {'body': orig_body}
(cmds, body) = pq.parse_gbp_commands(info, 'tag', ['cmd'], ['argcmd'], ['cmd'])
self.assertEquals(cmds, {'cmd': None})
self.assertEquals(body, 'Foo')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment