From 4f308cdf623cc4aca515fef0f0afed7cf2c990d2 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 20 Jun 2012 22:17:07 +0200 Subject: [PATCH] submittodebian: Style tweaks --- submittodebian | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/submittodebian b/submittodebian index 3fb482f..fd3652a 100755 --- a/submittodebian +++ b/submittodebian @@ -43,15 +43,18 @@ except ImportError: u"which isn't currently installed.") sys.exit(1) + def get_most_recent_debian_version(changelog): for block in changelog: version = block.version.full_version if not re.search('(ubuntu|build)', version): return version + def get_bug_body(changelog): entry = next(iter(changelog)) - msg = """In Ubuntu, the attached patch was applied to achieve the following: + msg = """ +In Ubuntu, the attached patch was applied to achieve the following: ## ---------------- REPLACE THIS WITH ACTUAL INFORMATION --------------------- ## Please add all necessary information about why the change needed to go in @@ -66,6 +69,7 @@ Thanks for considering the patch. """ % ("\n".join([a for a in entry.changes()])) return msg + def build_source_package(): if os.path.isdir('.bzr'): cmd = ['bzr', 'bd', '-S', '--', '-uc', '-us', '-nc'] @@ -73,6 +77,7 @@ def build_source_package(): cmd = ['debuild', '-S', '-uc', '-us', '-nc'] check_call(cmd) + def gen_debdiff(tmpdir, changelog): pkg = changelog.package @@ -88,9 +93,9 @@ def gen_debdiff(tmpdir, changelog): print "Extracting bzr diff between %s and %s" % (oldver, newver) else: if oldver.epoch is not None: - oldver = str(oldver)[str(oldver).index(":")+1:] + oldver = str(oldver)[str(oldver).index(":") + 1:] if newver.epoch is not None: - newver = str(newver)[str(newver).index(":")+1:] + newver = str(newver)[str(newver).index(":") + 1:] olddsc = '../%s_%s.dsc' % (pkg, oldver) newdsc = '../%s_%s.dsc' % (pkg, newver) @@ -112,7 +117,8 @@ def gen_debdiff(tmpdir, changelog): return debdiff -def check_file(fname, critical = True): + +def check_file(fname, critical=True): if os.path.exists(fname): return fname else: @@ -121,6 +127,7 @@ def check_file(fname, critical = True): print u"Couldn't find «%s».\n" % fname sys.exit(1) + def submit_bugreport(body, debdiff, deb_version, changelog): try: devel = UbuntuDistroInfo().devel() @@ -147,7 +154,8 @@ def submit_bugreport(body, debdiff, deb_version, changelog): '--no-check-available', '--no-check-installed', '--pseudo-header', 'User: ubuntu-devel@lists.ubuntu.com', - '--pseudo-header', 'Usertags: origin-ubuntu %s ubuntu-patch' % devel, + '--pseudo-header', 'Usertags: origin-ubuntu %s ubuntu-patch' + % devel, '--tag', 'patch', '--attach', debdiff, '--bts', 'debian', @@ -197,6 +205,7 @@ reportbug --configure for its configuration wizard. if YesNoQuestion().ask("Continue submitting this bug", "yes") == "no": sys.exit(1) + def main(): description = 'Submit the Ubuntu changes in a package to Debian. ' + \ 'Run inside an unpacked Ubuntu source package.' @@ -209,7 +218,7 @@ def main(): sys.exit(1) check_reportbug_config() - changelog_file = (check_file('debian/changelog', critical = False) or + changelog_file = (check_file('debian/changelog', critical=False) or check_file('../debian/changelog')) changelog = Changelog(file(changelog_file).read())