]> git.decadent.org.uk Git - dak.git/blobdiff - lisa
sync
[dak.git] / lisa
diff --git a/lisa b/lisa
index 18d27d2b1a7bcd0d887e2645780786a52b04222e..e44f085619f4e9683deace6057ca2e70e5daad92 100755 (executable)
--- a/lisa
+++ b/lisa
@@ -2,7 +2,7 @@
 
 # Handles NEW and BYHAND packages
 # Copyright (C) 2001, 2002  James Troup <james@nocrew.org>
-# $Id: lisa,v 1.15 2002-05-22 16:55:13 troup Exp $
+# $Id: lisa,v 1.20 2002-11-26 16:15:56 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
 
 ################################################################################
 
-# TODO
-# ----
-
-# We don't check error codes very thoroughly; the old 'trust jennifer'
-# chess nut... db_access calls in particular
-
-# Possible TODO
-# -------------
-
-# Handle multiple different section/priorities (?)
-# hardcoded debianness (debian-installer, source priority etc.) (?)
-# Slang/ncurses interface (?)
-# write changed sections/priority back to katie for later processing (?)
-
-################################################################################
-
-import copy, errno, os, readline, string, stat, sys, tempfile;
+import copy, errno, os, readline, stat, sys, tempfile;
 import apt_pkg, apt_inst;
 import db_access, fernanda, katie, logging, utils;
 
 # Globals
-lisa_version = "$Revision: 1.15 $";
+lisa_version = "$Revision: 1.20 $";
 
 Cnf = None;
 Options = None;
@@ -78,7 +62,7 @@ reject_message = "";
 def reject (str, prefix="Rejected: "):
     global reject_message;
     if str:
-        reject_message = reject_message + prefix + str + "\n";
+        reject_message += prefix + str + "\n";
 
 def recheck():
     global reject_message;
@@ -113,15 +97,17 @@ def recheck():
         print "REJECT\n" + reject_message,;
         prompt = "[R]eject, Skip, Quit ?";
 
-        while string.find(prompt, answer) == -1:
+        while prompt.find(answer) == -1:
             answer = utils.our_raw_input(prompt);
             m = katie.re_default_answer.match(prompt);
             if answer == "":
                 answer = m.group(1);
-            answer = string.upper(answer[:1]);
+            answer = answer[:1].upper();
 
         if answer == 'R':
             Katie.do_reject(0, reject_message);
+            os.unlink(Katie.pkg.changes_file[:-8]+".katie");
+            return 0;
         elif answer == 'S':
             return 0;
         elif answer == 'Q':
@@ -221,8 +207,10 @@ def sg_compare (a, b):
     # Sort by have note
     a_note_state = a["note_state"];
     b_note_state = b["note_state"];
-    if a_note_state != b_note_state:
-        return cmp(a, b);
+    if a_note_state < b_note_state:
+        return -1;
+    elif a_note_state > b_note_state:
+        return 1;
 
     # Sort by time of oldest upload
     return cmp(a["oldest"], b["oldest"]);
@@ -265,7 +253,7 @@ def sort_changes(changes_files):
             ctime = os.stat(d["filename"])[stat.ST_CTIME];
             if ctime < oldest:
                 oldest = ctime;
-            have_note = have_note + (d.has_key("lisa note"));
+            have_note += (d.has_key("lisa note"));
         per_source[source]["oldest"] = oldest;
         if not have_note:
             per_source[source]["note_state"] = 0; # none
@@ -274,10 +262,10 @@ def sort_changes(changes_files):
         else:
             per_source[source]["note_state"] = 2; # all
         per_source[source]["list"].sort(indiv_sg_compare);
-    per_source_items =  per_source.items();
+    per_source_items = per_source.items();
     per_source_items.sort(sg_compare);
     for i in per_source_items:
-        for j in  i[1]["list"]:
+        for j in i[1]["list"]:
             sorted_list.append(j["filename"]);
     return sorted_list;
 
@@ -347,20 +335,20 @@ def print_new (new, indexed, file=sys.stdout):
     broken = 0;
     index = 0;
     for pkg in new.keys():
-        index = index + 1;
+        index += 1;
         section = new[pkg]["section"];
         priority = new[pkg]["priority"];
         if new[pkg]["section id"] == -1:
-            section = section + "[!]";
+            section += "[!]";
             broken = 1;
         if new[pkg]["priority id"] == -1:
-            priority = priority + "[!]";
+            priority += "[!]";
             broken = 1;
         if indexed:
             line = "(%s): %-20s %-20s %-20s" % (index, pkg, priority, section);
         else:
             line = "%-20s %-20s %-20s" % (pkg, priority, section);
-        line = string.strip(line)+'\n';
+        line = line.strip()+'\n';
         file.write(line);
     note = Katie.pkg.changes.get("lisa note");
     if note:
@@ -418,10 +406,10 @@ def edit_new (new):
     os.unlink(temp_filename);
     # Parse the new data
     for line in lines:
-        line = string.strip(line[:-1]);
+        line = line.strip();
         if line == "":
             continue;
-        s = string.split(line);
+        s = line.split();
         # Pad the list if necessary
         s[len(s):3] = [None] * (3-len(s));
         (pkg, priority, section) = s[:3];
@@ -429,9 +417,9 @@ def edit_new (new):
             utils.warn("Ignoring unknown package '%s'" % (pkg));
         else:
             # Strip off any invalid markers, print_new will readd them.
-            if section[-3:] == "[!]":
+            if section.endswith("[!]"):
                 section = section[:-3];
-            if priority[-3:] == "[!]":
+            if priority.endswith("[!]"):
                 priority = priority[:-3];
             for file in new[pkg]["files"]:
                 Katie.pkg.files[file]["section"] = section;
@@ -447,7 +435,7 @@ def edit_index (new, index):
     type = new[index]["type"];
     done = 0
     while not done:
-        print string.join([index, priority, section], '\t');
+        print "\t".join([index, priority, section]);
 
         answer = "XXX";
         if type != "dsc":
@@ -456,12 +444,12 @@ def edit_index (new, index):
             prompt = "[S]ection, Done ? ";
         edit_priority = edit_section = 0;
 
-        while string.find(prompt, answer) == -1:
+        while prompt.find(answer) == -1:
             answer = utils.our_raw_input(prompt);
             m = katie.re_default_answer.match(prompt)
             if answer == "":
                 answer = m.group(1)
-            answer = string.upper(answer[:1])
+            answer = answer[:1].upper()
 
         if answer == 'P':
             edit_priority = 1;
@@ -477,7 +465,7 @@ def edit_index (new, index):
             readline.set_completer(Priorities.complete);
             got_priority = 0;
             while not got_priority:
-                new_priority = string.strip(utils.our_raw_input("New priority: "));
+                new_priority = utils.our_raw_input("New priority: ").strip();
                 if Priorities.priorities.count(new_priority) == 0:
                     print "E: '%s' is not a valid priority, try again." % (new_priority);
                 else:
@@ -489,7 +477,7 @@ def edit_index (new, index):
             readline.set_completer(Sections.complete);
             got_section = 0;
             while not got_section:
-                new_section = string.strip(utils.our_raw_input("New section: "));
+                new_section = utils.our_raw_input("New section: ").strip();
                 if Sections.sections.count(new_section) == 0:
                     print "E: '%s' is not a valid section, try again." % (new_section);
                 else:
@@ -516,7 +504,7 @@ def edit_overrides (new):
         new_index = {};
         index = 0;
         for i in new.keys():
-            index = index + 1;
+            index += 1;
             new_index[index] = i;
 
         prompt = "(%s) edit override <n>, Editor, Done ? " % (index_range(index));
@@ -524,7 +512,7 @@ def edit_overrides (new):
         got_answer = 0
         while not got_answer:
             answer = utils.our_raw_input(prompt);
-            answer = string.upper(answer[:1]);
+            answer = answer[:1].upper();
             if answer == "E" or answer == "D":
                 got_answer = 1;
             elif katie.re_isanum.match (answer):
@@ -558,18 +546,18 @@ def edit_note(note):
     while answer == 'E':
         os.system("%s %s" % (editor, temp_filename))
         temp_file = utils.open_file(temp_filename);
-        note = string.rstrip(temp_file.read());
+        note = temp_file.read().rstrip();
         temp_file.close();
         print "Note:";
         print utils.prefix_multi_line_string(note,"  ");
         prompt = "[D]one, Edit, Abandon, Quit ?"
         answer = "XXX";
-        while string.find(prompt, answer) == -1:
+        while prompt.find(answer) == -1:
             answer = utils.our_raw_input(prompt);
             m = katie.re_default_answer.search(prompt);
             if answer == "":
                 answer = m.group(1);
-            answer = string.upper(answer[:1]);
+            answer = answer[:1].upper();
     os.unlink(temp_filename);
     if answer == 'A':
         return;
@@ -582,7 +570,7 @@ def edit_note(note):
 
 def check_pkg ():
     try:
-        less_fd = os.popen("less -", 'w', 0);
+        less_fd = os.popen("less -R -", 'w', 0);
         stdout_fd = sys.stdout;
         try:
             sys.stdout = less_fd;
@@ -617,9 +605,9 @@ def do_bxa_notification():
     for file in files.keys():
         if files[file]["type"] == "deb":
             control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(file)));
-            summary = summary + "\n";
-            summary = summary + "Package: %s\n" % (control.Find("Package"));
-            summary = summary + "Description: %s\n" % (control.Find("Description"));
+            summary += "\n";
+            summary += "Package: %s\n" % (control.Find("Package"));
+            summary += "Description: %s\n" % (control.Find("Description"));
     Katie.Subst["__BINARY_DESCRIPTIONS__"] = summary;
     bxa_mail = utils.TemplateSubst(Katie.Subst,Cnf["Dir::Templates"]+"/lisa.bxa_notification");
     utils.send_mail(bxa_mail,"");
@@ -693,16 +681,16 @@ def do_new():
             print "W: [!] marked entries must be fixed before package can be processed.";
         if note:
             print "W: note must be removed before package can be processed.";
-            prompt = prompt + "Remove note, ";
+            prompt += "Remove note, ";
 
-        prompt = prompt + "Edit overrides, Check, Manual reject, Note edit, [S]kip, Quit ?";
+        prompt += "Edit overrides, Check, Manual reject, Note edit, [S]kip, Quit ?";
 
-        while string.find(prompt, answer) == -1:
+        while prompt.find(answer) == -1:
             answer = utils.our_raw_input(prompt);
             m = katie.re_default_answer.search(prompt);
             if answer == "":
                 answer = m.group(1)
-            answer = string.upper(answer[:1])
+            answer = answer[:1].upper()
 
         if answer == 'A':
             done = add_overrides (new);
@@ -718,7 +706,7 @@ def do_new():
         elif answer == 'N':
             edit_note(changes.get("lisa note", ""));
         elif answer == 'R':
-            confirm = string.lower(utils.our_raw_input("Really clear note (y/N)? "));
+            confirm = utils.our_raw_input("Really clear note (y/N)? ").lower();
             if confirm == "y":
                 del changes["lisa note"];
         elif answer == 'S':
@@ -806,12 +794,12 @@ def do_byhand():
         else:
             prompt = "Manual reject, [S]kip, Quit ?";
 
-        while string.find(prompt, answer) == -1:
+        while prompt.find(answer) == -1:
             answer = utils.our_raw_input(prompt);
             m = katie.re_default_answer.search(prompt);
             if answer == "":
                 answer = m.group(1);
-            answer = string.upper(answer[:1]);
+            answer = answer[:1].upper();
 
         if answer == 'A':
             done = 1;
@@ -891,7 +879,7 @@ def main():
 
     # Kill me now? **FIXME**
     Cnf["Dinstall::Options::No-Mail"] = "";
-    bcc = "X-Katie: %s" % (lisa_version);
+    bcc = "X-Katie: lisa %s" % (lisa_version);
     if Cnf.has_key("Dinstall::Bcc"):
         Katie.Subst["__BCC__"] = bcc + "\nBcc: %s" % (Cnf["Dinstall::Bcc"]);
     else: