From 0a3d905cf4d348968c0689bd8f7f267027bd5d34 Mon Sep 17 00:00:00 2001 From: Michael Bienia Date: Sun, 20 Dec 2009 15:43:57 +0100 Subject: [PATCH] ubuntutools/requestsync/mail.py: rmadison() returns now the most recent source line (Closes: #560758) --- debian/changelog | 4 +++- ubuntutools/requestsync/mail.py | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 05eb3cb..1a0e019 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,8 +11,10 @@ ubuntu-dev-tools (0.86) UNRELEASED; urgency=low [ Michael Bienia ] * ubuntutools/requestsync/common.py: convert the changelog into a unicode string (lp: #498349) + * ubuntutools/requestsync/mail.py: rmadison() returns now the most recent + source line (Closes: #560758) - -- Michael Bienia Sun, 20 Dec 2009 14:08:31 +0100 + -- Michael Bienia Sun, 20 Dec 2009 15:40:40 +0100 ubuntu-dev-tools (0.85) lucid; urgency=low diff --git a/ubuntutools/requestsync/mail.py b/ubuntutools/requestsync/mail.py index 8e7d41a..95fc5d9 100644 --- a/ubuntutools/requestsync/mail.py +++ b/ubuntutools/requestsync/mail.py @@ -24,6 +24,7 @@ import sys import subprocess import smtplib import socket +from debian_bundle.changelog import Version from .common import raw_input_exit_on_ctrlc from ..lp.udtexceptions import PackageNotFoundException @@ -63,13 +64,18 @@ def rmadison(distro, package, release): rmadison_out = rmadison_cmd.communicate()[0] assert (rmadison_cmd.returncode == 0) - # Work-around for a bug in Debians madison.php script not returning - # only the source line - for line in rmadison_out.splitlines(): - if line.find('source') > 0: - return map(lambda x: x.strip(), line.split('|')) - - return None + # Return the most recent source line + lines = rmadison_out.splitlines() + if not lines: + # no output + return None + lines = [map(lambda x: x.strip(), line.split('|')) for line in lines] + lines = [line for line in lines if line[3].find('source') != -1] + if lines: + return max(lines, key = lambda x: Version(x[1])) + else: + # no source line + return None def getSrcPkg(distro, name, release): out = rmadison(distro, name, release)