diff options
author | biao716.wang <biao716.wang@samsung.com> | 2019-11-14 16:17:06 +0800 |
---|---|---|
committer | biao716.wang <biao716.wang@samsung.com> | 2019-11-14 16:17:06 +0800 |
commit | 4696eb2a81eeb2af32cbdda8b0e612b3726ac1f7 (patch) | |
tree | 345a223e0387d52050c26f6d7bb52095953b31a7 | |
parent | f0a26b109d267557c949c5fe1012936a3f4d85a7 (diff) | |
download | git-buildpackage-4696eb2a81eeb2af32cbdda8b0e612b3726ac1f7.tar.gz git-buildpackage-4696eb2a81eeb2af32cbdda8b0e612b3726ac1f7.tar.bz2 git-buildpackage-4696eb2a81eeb2af32cbdda8b0e612b3726ac1f7.zip |
fix pylint error for git-buildpackage
Change-Id: Ia319032dcd3f55600bb79b5c85372a7a77122174
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rw-r--r-- | gbp/patch_series.py | 2 | ||||
-rw-r--r-- | gbp/rpm/__init__.py | 4 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage.py | 8 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage_rpm.py | 16 | ||||
-rwxr-xr-x | gbp/scripts/import_dsc.py | 2 | ||||
-rwxr-xr-x | gbp/scripts/import_orig_rpm.py | 12 | ||||
-rwxr-xr-x | gbp/scripts/import_srpm.py | 2 | ||||
-rwxr-xr-x | gbp/scripts/pq.py | 4 | ||||
-rw-r--r-- | gbp/scripts/supercommand.py | 4 | ||||
-rw-r--r-- | gbp/tmpfile.py | 8 | ||||
-rwxr-xr-x | packaging/git-buildpackage.spec | 1 | ||||
-rw-r--r-- | tests/04_test_submodules.py | 12 | ||||
-rw-r--r-- | tests/context.py | 1 | ||||
-rw-r--r-- | tests/test_rpm_changelog.py | 10 |
14 files changed, 45 insertions, 41 deletions
diff --git a/gbp/patch_series.py b/gbp/patch_series.py index 327997f5..6ca24f2c 100644 --- a/gbp/patch_series.py +++ b/gbp/patch_series.py @@ -72,7 +72,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 = body.read() body.close() except IOError as msg: raise GbpError("Failed to read patch header of '%s': %s" % diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py index d5fa1ee8..0fe2b4d8 100644 --- a/gbp/rpm/__init__.py +++ b/gbp/rpm/__init__.py @@ -804,9 +804,9 @@ def parse_srpm(srpmfile): try: srcrpm = SrcRpmFile(srpmfile) except IOError, err: - raise GbpError, "Error reading src.rpm file: %s" % err + raise GbpError("Error reading src.rpm file: %s" % err) except librpm.error, err: - raise GbpError, "RPM error while reading src.rpm: %s" % err + raise GbpError("RPM error while reading src.rpm: %s" % err) return srcrpm diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index cef0584f..43dc261e 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -166,8 +166,8 @@ def move_old_export(target): """move a build tree away if it exists""" try: os.mkdir(target) - except OSError as (e, msg): - if e == errno.EEXIST: + except OSError as msg: + if msg.errno == errno.EEXIST: os.rename(target, "%s.obsolete.%s" % (target, time.time())) @@ -213,8 +213,8 @@ def prepare_output_dir(dir): try: os.mkdir(output_dir) - except OSError as (e, msg): - if e != errno.EEXIST: + except OSError as msg: + if msg.errno != errno.EEXIST: raise GbpError("Cannot create output dir %s" % output_dir) return output_dir diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 56db5e13..7708dfce 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -110,9 +110,9 @@ def makedir(dir): """Create directory""" try: os.mkdir(dir) - except OSError, (e, msg): - if e != errno.EEXIST: - raise GbpError, "Cannot create dir %s" % dir + except OSError as msg: + if msg.errno != errno.EEXIST: + raise GbpError("Cannot create dir %s" % dir) return dir @@ -335,8 +335,8 @@ def update_tag_str_fields(fields, tag_format_str, repo, commit_info): committimenum=fields['committime'] + ".(?P<commitnum>[0-9]+)") try: tag_re = re.compile("^%s$" % (tag_format_str % re_fields)) - except KeyError, err: - raise GbpError, "Unknown field '%s' in packaging-tag format string" % err + except KeyError as err: + raise GbpError("Unknown field '%s' in packaging-tag format string" % err) fields['nowtimenum'] = fields['nowtime'] + ".1" fields['authortimenum'] = fields['authortime'] + ".1" @@ -559,12 +559,12 @@ def main(argv): if not ret: gbp.log.err("You have uncommitted changes in your source tree:") gbp.log.err(out) - raise GbpError, "Use --git-ignore-new or --git-ignore-untracked to ignore." + raise GbpError("Use --git-ignore-new or --git-ignore-untracked to ignore.") if not options.ignore_new and not options.ignore_branch: if branch != options.packaging_branch: gbp.log.err("You are not on branch '%s' but on '%s'" % (options.packaging_branch, branch)) - raise GbpError, "Use --git-ignore-branch to ignore or --git-packaging-branch to set the branch name." + raise GbpError("Use --git-ignore-branch to ignore or --git-packaging-branch to set the branch name.") # Dump from git to a temporary directory: dump_dir = tempfile.mkdtemp(dir=options.tmp_dir, @@ -605,7 +605,7 @@ def main(argv): try: shutil.copy2(src, dst) except IOError as err: - raise GbpError, "Error exporting files: %s" % err + raise GbpError("Error exporting files: %s" % err) spec.specdir = os.path.abspath(spec_dir) if options.orig_prefix != 'auto': diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index b19d95fc..41eae8c7 100755 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -144,7 +144,7 @@ def apply_debian_patch(repo, unpack_dir, src, options, tag): raise GbpError if os.path.exists('debian/rules'): - os.chmod('debian/rules', 0755) + os.chmod('debian/rules', 0o755) os.chdir(repo.path) parents = check_parents(repo, diff --git a/gbp/scripts/import_orig_rpm.py b/gbp/scripts/import_orig_rpm.py index b1247f1e..4b318a2c 100755 --- a/gbp/scripts/import_orig_rpm.py +++ b/gbp/scripts/import_orig_rpm.py @@ -76,7 +76,7 @@ def detect_name_and_version(repo, source, spec, options): if guessed_package: sourcepackage = guessed_package else: - raise GbpError, "Couldn't determine upstream package name. Use --interactive." + raise GbpError("Couldn't determine upstream package name. Use --interactive.") # Try to find the version. if options.version: @@ -90,7 +90,7 @@ def detect_name_and_version(repo, source, spec, options): if guessed_version: version = guessed_version else: - raise GbpError, "Couldn't determine upstream version. Use '-u<version>' or --interactive." + raise GbpError ("Couldn't determine upstream version. Use '-u<version>' or --interactive.") return (sourcepackage, version) @@ -228,7 +228,7 @@ def main(argv): try: repo = RpmGitRepository('.') except GitRepositoryError: - raise GbpError, "%s is not a git repository" % (os.path.abspath('.')) + raise GbpError ("%s is not a git repository" % (os.path.abspath('.'))) spec = find_spec(repo, options) source = find_source(spec, options, args) @@ -252,7 +252,7 @@ def main(argv): (clean, out) = repo.is_clean() if not clean and not is_empty: gbp.log.err("Repository has uncommitted changes, commit these first: ") - raise GbpError, out + raise GbpError(out) if repo.bare: set_bare_repo_options(options) @@ -313,7 +313,7 @@ def main(argv): try: repo.merge(tag) except GitRepositoryError: - raise GbpError, """Merge failed, please resolve.""" + raise GbpError("""Merge failed, please resolve.""") else: repo.create_branch(options.packaging_branch, rev=options.upstream_branch) if repo.get_branch() == options.packaging_branch: @@ -330,7 +330,7 @@ def main(argv): current_branch == repo.pristine_tar_branch): repo.force_head(current_branch, hard=True) except (GitRepositoryError, gbpc.CommandExecFailed): - raise GbpError, "Import of %s failed" % source.path + raise GbpError("Import of %s failed" % source.path) except GbpError, err: if len(err.__str__()): gbp.log.err(err) diff --git a/gbp/scripts/import_srpm.py b/gbp/scripts/import_srpm.py index 85f1225f..b573f2bc 100755 --- a/gbp/scripts/import_srpm.py +++ b/gbp/scripts/import_srpm.py @@ -306,7 +306,7 @@ def main(argv): if not clean and not is_empty: gbp.log.err("Repository has uncommitted changes, commit " "these first: ") - raise GbpError, out + raise GbpError(out) except GitRepositoryError: gbp.log.info("No git repository found, creating one.") diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 7053d0af..f15753ce 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -167,8 +167,8 @@ def export_patches(repo, branch, options): pq_branch = pq_branch_name(branch, options) try: shutil.rmtree(PATCH_DIR) - except OSError as (e, msg): - if e != errno.ENOENT: + except OSError as msg: + if msg.errno != errno.ENOENT: raise GbpError("Failed to remove patch dir: %s" % msg) else: gbp.log.debug("%s does not exist." % PATCH_DIR) diff --git a/gbp/scripts/supercommand.py b/gbp/scripts/supercommand.py index 83c8446b..493554f2 100644 --- a/gbp/scripts/supercommand.py +++ b/gbp/scripts/supercommand.py @@ -109,7 +109,9 @@ def supercommand(argv=None): usage() return 1 - prg, cmd = argv[0:2] + #prg, cmd = argv[0:2] prg is not used + cmd = argv[1] + args = argv[1:] if cmd in ['--help', '-h', 'help' ]: diff --git a/gbp/tmpfile.py b/gbp/tmpfile.py index e1ad3084..9435a810 100644 --- a/gbp/tmpfile.py +++ b/gbp/tmpfile.py @@ -26,13 +26,13 @@ def mkdtemp(dir, **kwargs): try: if not os.path.exists(dir): os.makedirs(dir) - except OSError as (dummy_e, msg): - raise GbpError, "Unable to create dir %s (%s)" % (dir, msg) + except OSError as msg: + raise GbpError("Unable to create dir %s (%s)" % (dir, msg)) try: return os.path.abspath(tempfile.mkdtemp(dir=dir, **kwargs)) - except OSError as (dummy_e, msg): - raise GbpError, "Unable to create tmpdir under %s (%s)" % (dir, msg) + except OSError as msg: + raise GbpError("Unable to create tmpdir under %s (%s)" % (dir, msg)) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff --git a/packaging/git-buildpackage.spec b/packaging/git-buildpackage.spec index 31dea18a..c85bdea4 100755 --- a/packaging/git-buildpackage.spec +++ b/packaging/git-buildpackage.spec @@ -11,6 +11,7 @@ BuildArch: noarch URL: https://honk.sigxcpu.org/piki/projects/git-buildpackage/ Source0: %{name}_%{version}.tar.gz + # Conditional package names for requirements %if 0%{?fedora} || 0%{?centos_ver} %define dpkg_pkg_name dpkg-devel diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py index 1b45c86f..7f4c6996 100644 --- a/tests/04_test_submodules.py +++ b/tests/04_test_submodules.py @@ -38,7 +38,7 @@ def setup(): TMPDIR = context.new_tmpdir(__name__) REPODIR = TMPDIR.join('test_repo') REPO = gbp.git.GitRepository.create(REPODIR) - + SUBMODULES = [] for name in SUBMODULE_NAMES: SUBMODULES.append(Submodule(name, str(TMPDIR))) @@ -134,11 +134,11 @@ def test_add_whitespace_submodule(): def test_get_more_submodules(): """Check for submodules list of (name, hash)""" - module = REPO.get_submodules("master") - eq_(len(module), len(SUBMODULE_NAMES)) - for module in REPO.get_submodules("master"): - eq_(len(module[1]) , 40) - ok_(os.path.basename(module[0]) in SUBMODULE_NAMES) + modules = REPO.get_submodules("master") + eq_(len(modules), len(SUBMODULE_NAMES)) + module = REPO.get_submodules("master")[0] + eq_(len(module[1]) , 40) + ok_(os.path.basename(module[0]) in SUBMODULE_NAMES) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff --git a/tests/context.py b/tests/context.py index cc3e25df..9800d85d 100644 --- a/tests/context.py +++ b/tests/context.py @@ -28,6 +28,7 @@ def chdir(dir): def new_tmpdir(name): global _tmpdirs + _tmpdirs = [] prefix='gbp_%s_' % name tmpdir = TmpDir(prefix) _tmpdirs.append(tmpdir) diff --git a/tests/test_rpm_changelog.py b/tests/test_rpm_changelog.py index 22739f0e..953919ec 100644 --- a/tests/test_rpm_changelog.py +++ b/tests/test_rpm_changelog.py @@ -31,14 +31,14 @@ class TestChangelogHeader(object): def test_str_format(self): """Basic test for header""" - time = datetime(2014, 01, 29, 12, 13, 14) + time = datetime(2014, 1, 29, 12, 13, 14) header = _ChangelogHeader(RpmPkgPolicy, time, name="John Doe", 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): """Test missing properties""" - time = datetime(2014, 01, 29, 12, 13, 14) + time = datetime(2014, 1, 29, 12, 13, 14) header = _ChangelogHeader(RpmPkgPolicy, time, name="John", revision="1") assert_raises(ChangelogError, str, header) @@ -74,7 +74,7 @@ class TestChangelogSection(object): def setup(self): """Initialize test""" - time = datetime(2014, 01, 29, 12, 13, 14) + time = datetime(2014, 1, 29, 12, 13, 14) self.default_sect = _ChangelogSection(RpmPkgPolicy, time, name="J. D.", email="u@h", revision="1") entry = _ChangelogEntry(RpmPkgPolicy, "J. D.", "- my change") @@ -99,7 +99,7 @@ class TestChangelogSection(object): def test_set_header(self): """Test set_header() method""" section = self.default_sect - time = datetime(2014, 01, 30) + time = datetime(2014, 1, 30) 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") @@ -239,7 +239,7 @@ class TestChangelog(object): def test_add_section(self): """Test the add_section() method""" changelog = Changelog(RpmPkgPolicy) - time = datetime(2014, 01, 30) + time = datetime(2014, 1, 30) new_section = changelog.add_section(time=time, name="Jane Doe", email="j@doe.com", revision="1.2") eq_(str(changelog), "* Thu Jan 30 2014 Jane Doe <j@doe.com> 1.2\n\n") |