← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jelmer/launchpad/520508-rely-on-newer-python-debian into lp:launchpad/devel

 

Jelmer Vernooij has proposed merging lp:~jelmer/launchpad/520508-rely-on-newer-python-debian into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
  #520508 Duplicate copy of split_gpg_and_payload()
  https://bugs.launchpad.net/bugs/520508


This branch cleans up some tech debt - we can now rely on a newer version of python-debian (included in sourcedeps), so there is no need for a custom copy of the GPG split function or import magic anymore

test: ./bin/test lp.soyuz.scripts.tests.test_sync_source
-- 
https://code.launchpad.net/~jelmer/launchpad/520508-rely-on-newer-python-debian/+merge/35405
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jelmer/launchpad/520508-rely-on-newer-python-debian into lp:launchpad/devel.
=== modified file 'scripts/ftpmaster-tools/sync-source.py'
--- scripts/ftpmaster-tools/sync-source.py	2010-08-27 12:21:25 +0000
+++ scripts/ftpmaster-tools/sync-source.py	2010-09-14 13:57:51 +0000
@@ -18,15 +18,7 @@
 
 import apt_pkg
 import commands
-try:
-    from debian.deb822 import Dsc
-except ImportError:
-    # In older versions of python-debian the main package was named
-    # debian_bundle
-    # XXX: Remove this when an up to date version of python-debian lands in
-    # the PPA or Ubuntu. Maverick will be the first release that has an
-    # up to date version of python-debian.
-    from debian_bundle.deb822 import Dsc
+from debian.deb822 import Dsc
 
 import errno
 import optparse
@@ -374,69 +366,6 @@
                 source, source_component, binary, current_version,
                 current_component)
 
-def split_gpg_and_payload(sequence):
-    """Return a (gpg_pre, payload, gpg_post) tuple
-
-    Each element of the returned tuple is a list of lines (with trailing
-    whitespace stripped).
-    """
-    # XXX JRV 20100211: Copied from deb822.py in python-debian. When
-    # Launchpad switches to Lucid this copy should be removed.
-    # bug=520508
-
-    gpg_pre_lines = []
-    lines = []
-    gpg_post_lines = []
-    state = 'SAFE'
-    gpgre = re.compile(r'^-----(?P<action>BEGIN|END) PGP (?P<what>[^-]+)-----$')
-    blank_line = re.compile('^$')
-    first_line = True
-
-    for line in sequence:
-        line = line.strip('\r\n')
-
-        # skip initial blank lines, if any
-        if first_line:
-            if blank_line.match(line):
-                continue
-            else:
-                first_line = False
-
-        m = gpgre.match(line)
-
-        if not m:
-            if state == 'SAFE':
-                if not blank_line.match(line):
-                    lines.append(line)
-                else:
-                    if not gpg_pre_lines:
-                        # There's no gpg signature, so we should stop at
-                        # this blank line
-                        break
-            elif state == 'SIGNED MESSAGE':
-                if blank_line.match(line):
-                    state = 'SAFE'
-                else:
-                    gpg_pre_lines.append(line)
-            elif state == 'SIGNATURE':
-                gpg_post_lines.append(line)
-        else:
-            if m.group('action') == 'BEGIN':
-                state = m.group('what')
-            elif m.group('action') == 'END':
-                gpg_post_lines.append(line)
-                break
-            if not blank_line.match(line):
-                if not lines:
-                    gpg_pre_lines.append(line)
-                else:
-                    gpg_post_lines.append(line)
-
-    if len(lines):
-        return (gpg_pre_lines, lines, gpg_post_lines)
-    else:
-        raise EOFError('only blank lines found in input')
-
 
 def import_dsc(dsc_filename, suite, previous_version, signing_rules,
                files_from_librarian, requested_by, origin, current_sources,
@@ -446,10 +375,7 @@
 
     if signing_rules.startswith("must be signed"):
         dsc_file.seek(0)
-        # XXX JRV 20100211: When Launchpad starts depending on Lucid,
-        # use dsc.split_gpg_and_payload() instead.
-        # bug=520508
-        (gpg_pre, payload, gpg_post) = split_gpg_and_payload(dsc_file)
+        (gpg_pre, payload, gpg_post) = Dsc.split_gpg_and_payload(dsc_file)
         if gpg_pre == [] and gpg_post == []:
             dak_utils.fubar("signature required for %s but not present"
                 % dsc_filename)


Follow ups