[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: New.html in RFC 822 format



On Wed, 18 Feb 2009, Joerg Jaspert wrote:

And thats a no-go, i think. We would have to run twice per .deb file in
NEW, which is an unneccessary waste.
Instead you should *additionally* output .822, when called with that
option.

See attached (as previousely said untested!) patch.  I have no idea
regarding performance and which loop makes the most effort - so perhaps
the iteration "for ext in ('.html', '.822') should be done at a different
level - perhaps even in main.

Just keep me informed if further work from my side is wanted.

Kind regards

       Andreas.

--
http://fam-tille.de
--- dak/show_new.py.orig	2009-01-20 22:15:09.000000000 +0100
+++ dak/show_new.py	2009-02-19 16:04:46.000000000 +0100
@@ -153,33 +153,43 @@
 
     stdout_fd = sys.stdout
 
-    htmlname = changes["source"] + "_" + changes["version"] + ".html"
-    sources.add(htmlname)
-    # do not generate html output if that source/version already has one.
-    if not os.path.exists(os.path.join(Cnf["Show-New::HTMLPath"],htmlname)):
-        sys.stdout = open(os.path.join(Cnf["Show-New::HTMLPath"],htmlname),"w")
-
-        filestoexamine = []
-        for pkg in new.keys():
-            for fn in new[pkg]["files"]:
-                if ( files[fn].has_key("new") and not
-                     files[fn]["type"] in [ "orig.tar.gz", "orig.tar.bz2", "tar.gz", "tar.bz2", "diff.gz", "diff.bz2"] ):
-                    filestoexamine.append(fn)
-
-        html_header(changes["source"], filestoexamine)
-
-        queue.check_valid(new)
-        examine_package.display_changes( distribution, Upload.pkg.changes_file)
-
-        for fn in filter(lambda fn: fn.endswith(".dsc"), filestoexamine):
-            examine_package.check_dsc(distribution, fn)
-        for fn in filter(lambda fn: fn.endswith(".deb") or fn.endswith(".udeb"), filestoexamine):
-            examine_package.check_deb(distribution, fn)
-
-        html_footer()
-        if sys.stdout != stdout_fd:
-            sys.stdout.close()
-            sys.stdout = stdout_fd
+    sourcename = changes["source"] + "_" + changes["version"]
+    for ext in (".html", ".822"):
+        if ext == ".822":
+            examine_package.use_html=0
+        else:
+            examine_package.use_html=1
+        htmlname = sourcename+ext
+        sources.add(htmlname)
+        # do not generate html output if that source/version already has one.
+        if not os.path.exists(os.path.join(Cnf["Show-New::HTMLPath"],htmlname)):
+            sys.stdout = open(os.path.join(Cnf["Show-New::HTMLPath"],htmlname),"w")
+
+            ## Remark: I'm not fully sure whether this piece of code should rather
+            ##         be placed outside of the "for ext" loop
+            filestoexamine = []
+            for pkg in new.keys():
+                for fn in new[pkg]["files"]:
+                    if ( files[fn].has_key("new") and not
+                         files[fn]["type"] in [ "orig.tar.gz", "orig.tar.bz2", "tar.gz", "tar.bz2", "diff.gz", "diff.bz2"] ):
+                        filestoexamine.append(fn)
+
+            if ext == '.html':
+                html_header(changes["source"], filestoexamine)
+
+            queue.check_valid(new)
+            examine_package.display_changes( distribution, Upload.pkg.changes_file)
+
+            for fn in filter(lambda fn: fn.endswith(".dsc"), filestoexamine):
+                examine_package.check_dsc(distribution, fn)
+                for fn in filter(lambda fn: fn.endswith(".deb") or fn.endswith(".udeb"), filestoexamine):
+                    examine_package.check_deb(distribution, fn)
+
+            if ext == '.html':
+                html_footer()
+            if sys.stdout != stdout_fd:
+                sys.stdout.close()
+                sys.stdout = stdout_fd
 
 ################################################################################
 
@@ -223,8 +233,6 @@
 def main():
     changes_files = init()
 
-    examine_package.use_html=1
-
     for changes_file in changes_files:
         changes_file = utils.validate_changes_file_arg(changes_file, 0)
         if not changes_file:
@@ -232,7 +240,8 @@
         print "\n" + changes_file
         do_pkg (changes_file)
     files = set(os.listdir(Cnf["Show-New::HTMLPath"]))
-    to_delete = filter(lambda x: x.endswith(".html"), files.difference(sources))
+    for ext in (".html", ".822"):
+        to_delete = filter(lambda x: x.endswith(ext), files.difference(sources))
     for f in to_delete:
         os.remove(os.path.join(Cnf["Show-New::HTMLPath"],f))
 

Reply to: