From 408f962cb26936ae282bbee31f682784da73ab08 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Thu, 21 Jul 2016 15:59:16 +0200 Subject: dch: PEP-8 cleanups --- gbp/deb/git.py | 8 ++++---- gbp/scripts/dch.py | 40 +++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/gbp/deb/git.py b/gbp/deb/git.py index b4b8fbad..64cd321a 100644 --- a/gbp/deb/git.py +++ b/gbp/deb/git.py @@ -75,7 +75,7 @@ class DebianGitRepository(GitRepository): """ tag = self.version_to_tag(format, version) legacy_tag = self._build_legacy_tag(format, version) - if self.has_tag(tag): # new tags are injective + if self.has_tag(tag): # new tags are injective # dereference to a commit object return self.rev_parse("%s^0" % tag) elif self.has_tag(legacy_tag): @@ -86,7 +86,7 @@ class DebianGitRepository(GitRepository): if line.endswith(" %s\n" % version): # dereference to a commit object return self.rev_parse("%s^0" % legacy_tag) - elif line.startswith('---'): # GPG signature start + elif line.startswith('---'): # GPG signature start return None return None @@ -127,7 +127,7 @@ class DebianGitRepository(GitRepository): >>> DebianGitRepository._build_legacy_tag('upstream/%(version)s', '1:2.0~3') 'upstream/2.0.3' """ - if ':' in version: # strip of any epochs + if ':' in version: # strip of any epochs version = version.split(':', 1)[1] version = version.replace('~', '.') return format % dict(version=version) @@ -149,7 +149,7 @@ class DebianGitRepository(GitRepository): """ return format_str(format, dict(version=DebianGitRepository._sanitize_version(version), - hversion=DebianGitRepository._sanitize_version(version).replace('.','-'))) + hversion=DebianGitRepository._sanitize_version(version).replace('.', '-'))) @staticmethod def _sanitize_version(version): diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index 2f6b6c6a..53cf8d92 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -61,11 +61,15 @@ def get_author_email(repo, use_git_config): author = email = None if use_git_config: - try: author = repo.get_config('user.name') - except KeyError: pass + try: + author = repo.get_config('user.name') + except KeyError: + pass - try: email = repo.get_config('user.email') - except KeyError: pass + try: + email = repo.get_config('user.email') + except KeyError: + pass return author, email @@ -81,7 +85,7 @@ def fixup_section(repo, use_git_author, options, dch_options): author, email = get_author_email(repo, use_git_author) used_options = ['distribution', 'urgency'] opts = [] - mainttrailer_opts = [ '--nomainttrailer', '--mainttrailer', '-t' ] + mainttrailer_opts = ['--nomainttrailer', '--mainttrailer', '-t'] # This must not be done for snapshots or snapshots changelog entries # will not be concatenated @@ -100,7 +104,7 @@ def fixup_section(repo, use_git_author, options, dch_options): break else: opts.append(mainttrailer_opts[0]) - ChangeLog.spawn_dch(msg='', author=author, email=email, dch_options=dch_options+opts) + ChangeLog.spawn_dch(msg='', author=author, email=email, dch_options=dch_options + opts) def snapshot_version(version): @@ -118,12 +122,12 @@ def snapshot_version(version): """ try: (release, suffix) = version.rsplit('~', 1) - (snapshot, commit) = suffix.split('.', 1) + (snapshot, commit) = suffix.split('.', 1) if not commit.startswith('gbp'): raise ValueError else: snapshot = int(snapshot) - except ValueError: # not a snapshot release + except ValueError: # not a snapshot release release = version snapshot = 0 return release, snapshot @@ -143,13 +147,13 @@ def mangle_changelog(changelog, cp, snapshot=''): cr = open(changelog, 'r') print("%(Source)s (%(MangledVersion)s) " - "%(Distribution)s; urgency=%(urgency)s\n" % cp, file=cw) + "%(Distribution)s; urgency=%(urgency)s\n" % cp, file=cw) - cr.readline() # skip version and empty line + cr.readline() # skip version and empty line cr.readline() line = cr.readline() if snapshot_re.match(line): - cr.readline() # consume the empty line after the snapshot header + cr.readline() # consume the empty line after the snapshot header line = '' if snapshot: @@ -193,6 +197,7 @@ def do_snapshot(changelog, repo, next_snapshot): mangle_changelog(changelog, cp, commit) return snapshot, commit, cp['MangledVersion'] + def parse_commit(repo, commitid, opts, last_commit=False): """Parse a commit and return message, author, and author email""" commit_info = repo.get_commit_info(commitid) @@ -320,7 +325,7 @@ def build_parser(name): parser.add_option_group(naming_group) parser.add_option_group(custom_group) - parser.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch") + parser.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch") naming_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") naming_group.add_config_file_option(option_name="debian-branch", dest="debian_branch") naming_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag") @@ -371,7 +376,7 @@ def build_parser(name): commit_group.add_boolean_config_file_option(option_name="multimaint-merge", dest="multimaint_merge") commit_group.add_config_file_option(option_name="spawn-editor", dest="spawn_editor") parser.add_config_file_option(option_name="commit-msg", - dest="commit_msg") + dest="commit_msg") parser.add_option("-c", "--commit", action="store_true", dest="commit", default=False, help="commit changelog file after generating") @@ -381,8 +386,6 @@ def build_parser(name): custom_group.add_config_file_option(option_name="customizations", dest="customization_file", help=help_msg) - - return parser @@ -443,7 +446,7 @@ def main(argv): msg = "Starting from first commit" gbp.log.info(msg) found_snapshot_banner = has_snapshot_banner(cp) - else: # Fallback: continue from last tag + else: # Fallback: continue from last tag since = repo.find_version(options.debian_tag, cp['Version']) if not since: raise GbpError("Version %s not found" % cp['Version']) @@ -456,7 +459,7 @@ def main(argv): # add a new changelog section if: if (options.new_version or options.bpo or options.nmu or options.qa or - options.team or options.security): + options.team or options.security): if options.bpo: version_change['increment'] = '--bpo' elif options.nmu: @@ -491,7 +494,7 @@ def main(argv): for c in commits: i += 1 parsed = parse_commit(repo, c, options, - last_commit = i == len(commits)) + last_commit=(i == len(commits))) commit_msg, (commit_author, commit_email) = parsed if not commit_msg: # Some commits can be ignored @@ -510,7 +513,6 @@ def main(argv): else: cp.add_entry(commit_msg, commit_author, commit_email, dch_options) - # Show a message if there were no commits (not even ignored # commits). if not commits: -- cgit v1.2.3