From 4edf024f09a7e8d813804dbba797efb95c3abfe6 Mon Sep 17 00:00:00 2001 From: James Troup Date: Sat, 18 May 2002 23:54:51 +0000 Subject: [PATCH] parse_changes and build_file_list 2nd argument sanity changes --- fernanda.py | 6 +++--- halle | 6 +++--- jennifer | 12 ++++++------ jeri | 6 +++--- melanie | 6 +++--- shania | 10 +++++----- utils.py | 22 +++++++++++----------- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/fernanda.py b/fernanda.py index c94aae25..9197a179 100755 --- a/fernanda.py +++ b/fernanda.py @@ -2,7 +2,7 @@ # Script to automate some parts of checking NEW packages # Copyright (C) 2000, 2001, 2002 James Troup -# $Id: fernanda.py,v 1.2 2002-05-03 16:06:45 troup Exp $ +# $Id: fernanda.py,v 1.3 2002-05-18 23:54:51 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -128,8 +128,8 @@ def display_changes (changes_filename): def check_changes (changes_filename): display_changes(changes_filename); - changes = utils.parse_changes (changes_filename, 0); - files = utils.build_file_list(changes, ""); + changes = utils.parse_changes (changes_filename); + files = utils.build_file_list(changes); for file in files.keys(): if file[-4:] == ".deb" or file[-5:] == ".udeb": check_deb(file); diff --git a/halle b/halle index e3ad2882..339fd262 100755 --- a/halle +++ b/halle @@ -2,7 +2,7 @@ # Remove obsolete .changes files from proposed-updates # Copyright (C) 2001, 2002 James Troup -# $Id: halle,v 1.6 2002-05-08 11:13:02 troup Exp $ +# $Id: halle,v 1.7 2002-05-18 23:54:51 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -49,8 +49,8 @@ Need either changes files or an admin.txt file with a '.joey' suffix.""" def check_changes (filename): try: - changes = utils.parse_changes(filename, 0) - files = utils.build_file_list(changes, ""); + changes = utils.parse_changes(filename); + files = utils.build_file_list(changes); except: utils.warn("Couldn't read changes file '%s'." % (filename)); return; diff --git a/jennifer b/jennifer index 3da7f8f2..7b3b5169 100755 --- a/jennifer +++ b/jennifer @@ -2,7 +2,7 @@ # Checks Debian packages from Incoming # Copyright (C) 2000, 2001, 2002 James Troup -# $Id: jennifer,v 1.19 2002-05-14 22:28:01 troup Exp $ +# $Id: jennifer,v 1.20 2002-05-18 23:54:51 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ re_is_changes = re.compile (r"(.+?)_(.+?)_(.+?)\.changes$"); ################################################################################ # Globals -jennifer_version = "$Revision: 1.19 $"; +jennifer_version = "$Revision: 1.20 $"; Cnf = None; Options = None; @@ -355,7 +355,7 @@ def check_changes(): # Parse the .changes field into a dictionary try: - changes.update(utils.parse_changes(filename, 0)); + changes.update(utils.parse_changes(filename)); except utils.cant_open_exc: reject("can't read changes file '%s'." % (filename)); return 0; @@ -365,7 +365,7 @@ def check_changes(): # Parse the Files field from the .changes into another dictionary try: - files.update(utils.build_file_list(changes, "")); + files.update(utils.build_file_list(changes)); except utils.changes_parse_error_exc, line: reject("error parsing changes file '%s', can't grok: %s." % (filename, line)); except utils.nk_format_exc, format: @@ -713,7 +713,7 @@ def check_dsc (): if files[file]["type"] == "dsc": # Parse the .dsc file try: - dsc.update(utils.parse_changes(file, 1)); + dsc.update(utils.parse_changes(file, dsc_whitespace_rules=1)); except utils.cant_open_exc: # if not -n copy_to_holding() will have done this for us... if Options["No-Action"]: @@ -724,7 +724,7 @@ def check_dsc (): reject("syntax error in .dsc file '%s', line %s." % (file, line)); # Build up the file list of files mentioned by the .dsc try: - dsc_files.update(utils.build_file_list(dsc, 1)); + dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1)); except utils.no_files_exc: reject("no Files: field in .dsc file."); continue; diff --git a/jeri b/jeri index 40594780..740f0ed7 100755 --- a/jeri +++ b/jeri @@ -2,7 +2,7 @@ # Dependency check proposed-updates # Copyright (C) 2001, 2002 James Troup -# $Id: jeri,v 1.6 2002-05-14 15:34:02 troup Exp $ +# $Id: jeri,v 1.7 2002-05-18 23:54:51 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -187,8 +187,8 @@ def pass_fail (filename, result): def check_changes (filename): try: - changes = utils.parse_changes(filename, 0) - files = utils.build_file_list(changes, ""); + changes = utils.parse_changes(filename); + files = utils.build_file_list(changes); except: utils.warn("Error parsing changes file '%s'" % (filename)); return; diff --git a/melanie b/melanie index 0ce57715..5e012e5d 100755 --- a/melanie +++ b/melanie @@ -2,7 +2,7 @@ # General purpose package removal tool for ftpmaster # Copyright (C) 2000, 2001, 2002 James Troup -# $Id: melanie,v 1.25 2002-05-16 18:01:33 rmurray Exp $ +# $Id: melanie,v 1.26 2002-05-18 23:54:51 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -255,7 +255,7 @@ def main (): for i in source_packages.keys(): filename = string.join(source_packages[i], '/'); try: - dsc = utils.parse_changes(filename, 0); + dsc = utils.parse_changes(filename); except utils.cant_open_exc: utils.warn("couldn't open '%s'." % (filename)); continue; @@ -394,7 +394,7 @@ def main (): Subst["__BCC__"] = "Bcc: " + string.join(bcc, ", "); else: Subst["__BCC__"] = "X-Filler: 42"; - Subst["__CC__"] = "X-Melanie: $Revision: 1.25 $"; + Subst["__CC__"] = "X-Melanie: $Revision: 1.26 $"; if carbon_copy: Subst["__CC__"] = Subst["__CC__"] + "\nCc: " + string.join(carbon_copy, ", "); Subst["__SUITE_LIST__"] = suites_list; diff --git a/shania b/shania index 6131cbc6..35577ec0 100755 --- a/shania +++ b/shania @@ -2,7 +2,7 @@ # Clean incoming of old unused files # Copyright (C) 2000, 2001, 2002 James Troup -# $Id: shania,v 1.14 2002-05-08 11:13:02 troup Exp $ +# $Id: shania,v 1.15 2002-05-18 23:54:51 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -129,8 +129,8 @@ def flush_orphans (): # Proces all .changes and .dsc files. for changes_filename in changes_files: try: - changes = utils.parse_changes(changes_filename, 0) - files = utils.build_file_list(changes, ""); + changes = utils.parse_changes(changes_filename); + files = utils.build_file_list(changes); except: utils.warn("error processing '%s'; skipping it. [Got %s]" % (changes_filename, sys.exc_type)); continue; @@ -139,8 +139,8 @@ def flush_orphans (): for file in files.keys(): if file[-4:] == ".dsc": try: - dsc = utils.parse_changes(file, 0) - dsc_files = utils.build_file_list(dsc, 1) + dsc = utils.parse_changes(file); + dsc_files = utils.build_file_list(dsc, is_a_dsc=1); except: utils.warn("error processing '%s'; skipping it. [Got %s]" % (file, sys.exc_type)); continue; diff --git a/utils.py b/utils.py index aca1df76..59beb2af 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ # Utility functions # Copyright (C) 2000, 2001, 2002 James Troup -# $Id: utils.py,v 1.43 2002-05-10 00:24:14 troup Exp $ +# $Id: utils.py,v 1.44 2002-05-18 23:54:51 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -import commands, os, pwd, re, socket, shutil, string, sys, tempfile +import os, pwd, re, socket, shutil, string, sys, tempfile import apt_pkg re_comments = re.compile(r"\#.*") @@ -123,7 +123,7 @@ def extract_component_from_section(section): # o The data section must end with a blank line and must be followed by # "-----BEGIN PGP SIGNATURE-----". -def parse_changes(filename, dsc_whitespace_rules): +def parse_changes(filename, dsc_whitespace_rules=0): changes_in = open_file(filename); error = ""; changes = {}; @@ -199,12 +199,12 @@ def parse_changes(filename, dsc_whitespace_rules): # Dropped support for 1.4 and ``buggy dchanges 3.4'' (?!) compared to di.pl -def build_file_list(changes, dsc): +def build_file_list(changes, is_a_dsc=0): files = {} format = changes.get("format", "") if format != "": format = float(format) - if dsc == "" and (format < 1.5 or format > 2.0): + if not is_a_dsc and (format < 1.5 or format > 2.0): raise nk_format_exc, format; # No really, this has happened. Think 0 length .dsc file. @@ -217,7 +217,7 @@ def build_file_list(changes, dsc): s = string.split(i) section = priority = ""; try: - if dsc != "": + if is_a_dsc: (md5, size, name) = s else: (md5, size, section, priority, name) = s @@ -428,12 +428,12 @@ def cc_fix_changes (changes): # Sort by source name, source version, 'have source', and then by filename def changes_compare (a, b): try: - a_changes = parse_changes(a, 0) + a_changes = parse_changes(a); except: return -1; try: - b_changes = parse_changes(b, 0) + b_changes = parse_changes(b); except: return 1; @@ -452,11 +452,11 @@ def changes_compare (a, b): b_version = b_changes.get("version"); q = apt_pkg.VersionCompare(a_version, b_version); if q: - return q + return q; # Sort by 'have source' - a_has_source = a_changes["architecture"].get("source") - b_has_source = b_changes["architecture"].get("source") + a_has_source = a_changes["architecture"].get("source"); + b_has_source = b_changes["architecture"].get("source"); if a_has_source and not b_has_source: return -1; elif b_has_source and not a_has_source: -- 2.39.5