[csw-devel] SF.net SVN: gar:[10757] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Tue Aug 17 10:56:13 CEST 2010


Revision: 10757
          http://gar.svn.sourceforge.net/gar/?rev=10757&view=rev
Author:   wahwah
Date:     2010-08-17 08:56:12 +0000 (Tue, 17 Aug 2010)

Log Message:
-----------
mGAR v2: pkgdb, the HTML template split out to a separate file.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/pkgdb.py

Added Paths:
-----------
    csw/mgar/gar/v2/lib/python/pkg-review-template.html

Added: csw/mgar/gar/v2/lib/python/pkg-review-template.html
===================================================================
--- csw/mgar/gar/v2/lib/python/pkg-review-template.html	                        (rev 0)
+++ csw/mgar/gar/v2/lib/python/pkg-review-template.html	2010-08-17 08:56:12 UTC (rev 10757)
@@ -0,0 +1,290 @@
+<html>
+#import pprint
+<head>
+<title>
+#for pkg in $pkgstats
+$pkg.pkginfo.PKG
+#end for
+</title>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+<style type="text/css">
+body { font-family: sans-serif; }
+p, td, th, li { font-size: 11px; }
+h1 { font-size: 16px; }
+h2 { font-size: 15px; }
+h3 { font-size: 14px; }
+h4 { font-size: 13px; }
+pre { background-color: #EEE; }
+ul.code {
+  list-style: none;
+  padding: 0px;
+  margin: 0px;
+}
+ul.code li {
+  font-family: monospace;
+  background-color: #EEE;
+}
+ul.clean {
+  list-style: none;
+  padding: 0px;
+  margin: 0px;
+}
+span.warning {
+  background-color: #DDF;
+}
+table.framed td {
+  border: 1px solid #DDD;
+}
+td.numeric {
+  text-align: right;
+}
+table.gently-lined td {
+  border-bottom: 1px solid #DDD;
+  margin: 0px;
+  padding: 2px;
+}
+table.gently-lined th {
+  border-bottom: 2px solid black;
+  margin: 0px;
+  padding: 2px;
+}
+</style>
+</head>
+<body>
+#for pkg in $pkgstats
+  <h1>$pkg.basic_stats.pkg_basename</h1>
+  <h2>Build source code</h2>
+#if $pkg.build_src
+  <p>
+    <a href="$pkg.build_src">
+      $pkg.build_src
+    </a>
+  </p>
+#else
+  <p>
+    <span style="warning">
+      Build source (OPENCSW_REPOSITORY) not specified in pkginfo.
+    </span>
+  </p>
+#end if
+	<p>
+	  <a href="http://www.opencsw.org/packages/$pkg.basic_stats.pkgname/">
+	    $pkg.basic_stats.pkgname</a>
+	  on the website.
+	</p>
+  <h2>Basic stats</h2>
+  <table>
+#for key in ('md5_sum', 'pkgname', 'stats_version', 'pkg_basename', 'catalogname')
+  <tr>
+  <td>
+  $key
+  </td>
+  <td>
+  <code>$pkg.basic_stats[$key]</code>
+  </td>
+  </tr>
+#end for
+  </table>
+  <h3>parsed basename</h3>
+  <table class="framed">
+  <!--
+
+{'arch': 'i386',
+ 'catalogname': 'mysql51',
+ 'full_version_string': '5.1.49,REV=2010.08.12',
+ 'osrel': 'SunOS5.9',
+ 'revision_info': {'REV': '2010.08.12'},
+ 'vendortag': 'CSW',
+ 'version': '5.1.49',
+ 'version_info': {'major version': '5',
+                  'minor version': '1',
+                  'patchlevel': '49'}}
+
+  mysql51-5.1.49,REV=2010.08.12-SunOS5.9-i386-CSW.pkg.gz
+  -->
+  <tr>
+    <th>catalogname</th>
+    <th>full_version_string</th>
+    <th>(version)</th>
+    <th>(version_info)</th>
+    <th>(revision_info)</th>
+    <th>osrel</th>
+    <th>arch</th>
+    <th>vendortag</th>
+  </tr>
+  <tr>
+    <td>$pkg.basic_stats.parsed_basename.catalogname</td>
+    <td>$pkg.basic_stats.parsed_basename.full_version_string</td>
+    <td>$pkg.basic_stats.parsed_basename.version</td>
+    <td>
+      <ul class="clean">
+#for key, val in $pkg.basic_stats.parsed_basename.version_info.iteritems
+        <li>$key: $val</li>
+#end for
+      </ul>
+    </td>
+    <td>
+      <ul class="clean">
+#for key, val in $pkg.basic_stats.parsed_basename.revision_info.iteritems
+        <li>$key: $val</li>
+#end for
+      </ul>
+    </td>
+    <td>$pkg.basic_stats.parsed_basename.osrel</td>
+    <td>$pkg.basic_stats.parsed_basename.arch</td>
+    <td>$pkg.basic_stats.parsed_basename.vendortag</td>
+  </tr>
+  </table>
+  <h2>pkginfo</h2>
+  <table class="gently-lined">
+  <tr>
+  <th>Key</th>
+  <th>Value</th>
+  </tr>
+#for key, val in $pkg.pkginfo.iteritems
+  <tr>
+  <td
+  >$key</td>
+  <td
+  ><code>$val</code></td>
+  </tr>
+#end for
+  </table>
+#if $pkg.binaries_dump_info
+  <h2>binaries_dump_info</h2>
+  <ul>
+#for bin in $pkg["binaries_dump_info"]
+  <li>
+  <strong>$bin.path</strong>
+## ['base_name', 'RUNPATH RPATH the same', 'runpath', 'RPATH set', 'needed sonames', 'path', 'RUNPATH set']
+  <ul>
+  <li>
+    base name: <code>$bin.base_name</code>
+  </li>
+  <li> runpath:
+    <ul>
+#for runpath_el in $bin.runpath
+      <li>
+        <code>
+            $runpath_el
+        </code>
+      </li>
+#end for
+    </ul>
+  <li> needed sonames:
+    <ul>
+#for soname in $bin["needed sonames"]
+      <li>
+        <code>
+          <a href="http://www.opencsw.org/packagesContainingFile/?fileName=$soname&searchsubmit=1">
+            $soname
+          </a>
+        </code>
+      </li>
+#end for
+    </ul>
+  </ul>
+  </li>
+#end for
+  </ul>
+#end if
+#if $pkg.depends
+  <h2>depends</h2>
+  <ul>
+#for depend_pkg, depend_desc in $pkg.depends
+  <li>
+    <a href="http://www.opencsw.org/packages/$depend_pkg/">
+      $depend_desc
+    </a>
+  </li>
+#end for
+  </ul>
+#end if
+#if $pkg.files_metadata
+  <h2>files metadata</h2>
+  <table class="gently-lined">
+  <tr>
+    <th>path</th>
+    <th>mimetype</th>
+    <th>machine name</th>
+    <!--
+    <th>endian</th>
+    -->
+  </tr>
+#for md in $pkg.files_metadata
+  <tr>
+  <td> $md.path </td>
+  <td> $md.mime_type </td>
+  <td style="text-align: center;">
+#if "machine_id" in $md
+  $hachoir_machines[$md.machine_id].name
+#else
+  &nbsp;
+#end if
+  </td>
+  <!--
+  <td>
+#if "endian" in $md
+  $md.endian
+#else
+  &nbsp;
+#end if
+  </td>
+  -->
+  </tr>
+#end for
+  </table>
+#end if
+#if $pkg.isalist
+  <h2>isalist</h2>
+  <ul class="code">
+#for isa in $pkg.isalist
+	  <li>
+	    $isa
+	  </li>
+#end for
+  </ul>
+#end if
+#if $pkg.mtime
+  <h2>mtime</h2>
+  <p>
+  $pkg.mtime
+  </p>
+#end if
+#if $pkg.overrides
+  <h2>overrides</h2>
+  <ul>
+#for override in $pkg.overrides
+  <li>
+  $override.pkgname
+  $override.tag_name
+  $override.tag_info
+  </li>
+#end for
+  </ul>
+#end if
+  <h2>pkgchk</h2>
+  <p>stdout</p>
+  <pre>
+#for l in $pkg.pkgchk.stdout_lines
+$l
+#end for
+  </pre>
+  <p>stderr</p>
+  <pre>
+#for l in $pkg.pkgchk.stderr_lines
+$l
+#end for
+  </pre>
+  <h2>pkgmap</h2>
+  <ul class="code">
+#for entry in $pkg.pkgmap
+  <li>
+  $entry.line
+  </li>
+#end for
+  </ul>
+#end for
+</body>
+</html>
+

Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py	2010-08-17 08:32:49 UTC (rev 10756)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py	2010-08-17 08:56:12 UTC (rev 10757)
@@ -35,297 +35,7 @@
 stats_version:  $stats_version
 """
 
-REVIEW_REQ_TMPL = """<html>
-#import pprint
-<head>
-<title>
-#for pkg in $pkgstats
-$pkg.pkginfo.PKG
-#end for
-</title>
-<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-<style type="text/css">
-body { font-family: sans-serif; }
-p, td, th, li { font-size: 11px; }
-h1 { font-size: 16px; }
-h2 { font-size: 15px; }
-h3 { font-size: 14px; }
-h4 { font-size: 13px; }
-pre { background-color: #EEE; }
-ul.code {
-  list-style: none;
-  padding: 0px;
-  margin: 0px;
-}
-ul.code li {
-  font-family: monospace;
-  background-color: #EEE;
-}
-ul.clean {
-  list-style: none;
-  padding: 0px;
-  margin: 0px;
-}
-span.warning {
-  background-color: #DDF;
-}
-table.framed td {
-  border: 1px solid #DDD;
-}
-td.numeric {
-  text-align: right;
-}
-table.gently-lined td {
-  border-bottom: 1px solid #DDD;
-  margin: 0px;
-  padding: 2px;
-}
-table.gently-lined th {
-  border-bottom: 2px solid black;
-  margin: 0px;
-  padding: 2px;
-}
-</style>
-</head>
-<body>
-#for pkg in $pkgstats
-  <h1>$pkg.basic_stats.pkg_basename</h1>
-  <h2>Build source code</h2>
-#if $pkg.build_src
-  <p>
-    <a href="$pkg.build_src">
-      $pkg.build_src
-    </a>
-  </p>
-#else
-  <p>
-    <span style="warning">
-      Build source (OPENCSW_REPOSITORY) not specified in pkginfo.
-    </span>
-  </p>
-#end if
-	<p>
-	  <a href="http://www.opencsw.org/packages/$pkg.basic_stats.pkgname/">
-	    $pkg.basic_stats.pkgname</a>
-	  on the website.
-	</p>
-  <h2>Basic stats</h2>
-  <table>
-#for key in ('md5_sum', 'pkgname', 'stats_version', 'pkg_basename', 'catalogname')
-  <tr>
-  <td>
-  $key
-  </td>
-  <td>
-  <code>$pkg.basic_stats[$key]</code>
-  </td>
-  </tr>
-#end for
-  </table>
-  <h3>parsed basename</h3>
-  <table class="framed">
-  <!--
 
-{'arch': 'i386',
- 'catalogname': 'mysql51',
- 'full_version_string': '5.1.49,REV=2010.08.12',
- 'osrel': 'SunOS5.9',
- 'revision_info': {'REV': '2010.08.12'},
- 'vendortag': 'CSW',
- 'version': '5.1.49',
- 'version_info': {'major version': '5',
-                  'minor version': '1',
-                  'patchlevel': '49'}}
-
-  mysql51-5.1.49,REV=2010.08.12-SunOS5.9-i386-CSW.pkg.gz
-  -->
-  <tr>
-    <th>catalogname</th>
-    <th>full_version_string</th>
-    <th>(version)</th>
-    <th>(version_info)</th>
-    <th>(revision_info)</th>
-    <th>osrel</th>
-    <th>arch</th>
-    <th>vendortag</th>
-  </tr>
-  <tr>
-    <td>$pkg.basic_stats.parsed_basename.catalogname</td>
-    <td>$pkg.basic_stats.parsed_basename.full_version_string</td>
-    <td>$pkg.basic_stats.parsed_basename.version</td>
-    <td>
-      <ul class="clean">
-#for key, val in $pkg.basic_stats.parsed_basename.version_info.iteritems
-        <li>$key: $val</li>
-#end for
-      </ul>
-    </td>
-    <td>
-      <ul class="clean">
-#for key, val in $pkg.basic_stats.parsed_basename.revision_info.iteritems
-        <li>$key: $val</li>
-#end for
-      </ul>
-    </td>
-    <td>$pkg.basic_stats.parsed_basename.osrel</td>
-    <td>$pkg.basic_stats.parsed_basename.arch</td>
-    <td>$pkg.basic_stats.parsed_basename.vendortag</td>
-  </tr>
-  </table>
-  <h2>pkginfo</h2>
-  <table class="gently-lined">
-  <tr>
-  <th>Key</th>
-  <th>Value</th>
-  </tr>
-#for key, val in $pkg.pkginfo.iteritems
-  <tr>
-  <td
-  >$key</td>
-  <td
-  ><code>$val</code></td>
-  </tr>
-#end for
-  </table>
-#if $pkg.binaries_dump_info
-  <h2>binaries_dump_info</h2>
-  <ul>
-#for bin in $pkg["binaries_dump_info"]
-  <li>
-  <strong>$bin.path</strong>
-## ['base_name', 'RUNPATH RPATH the same', 'runpath', 'RPATH set', 'needed sonames', 'path', 'RUNPATH set']
-  <ul>
-  <li>
-    base name: <code>$bin.base_name</code>
-  </li>
-  <li> runpath:
-    <ul>
-#for runpath_el in $bin.runpath
-      <li>
-        <code>
-            $runpath_el
-        </code>
-      </li>
-#end for
-    </ul>
-  <li> needed sonames:
-    <ul>
-#for soname in $bin["needed sonames"]
-      <li>
-        <code>
-          <a href="http://www.opencsw.org/packagesContainingFile/?fileName=$soname&searchsubmit=1">
-            $soname
-          </a>
-        </code>
-      </li>
-#end for
-    </ul>
-  </ul>
-  </li>
-#end for
-  </ul>
-#end if
-#if $pkg.depends
-  <h2>depends</h2>
-  <ul>
-#for depend_pkg, depend_desc in $pkg.depends
-  <li>
-    <a href="http://www.opencsw.org/packages/$depend_pkg/">
-      $depend_desc
-    </a>
-  </li>
-#end for
-  </ul>
-#end if
-#if $pkg.files_metadata
-  <h2>files metadata</h2>
-  <table class="gently-lined">
-  <tr>
-    <th>path</th>
-    <th>mimetype</th>
-    <th>machine name</th>
-    <!--
-    <th>endian</th>
-    -->
-  </tr>
-#for md in $pkg.files_metadata
-  <tr>
-  <td> $md.path </td>
-  <td> $md.mime_type </td>
-  <td style="text-align: center;">
-#if "machine_id" in $md
-  $hachoir_machines[$md.machine_id].name
-#else
-  &nbsp;
-#end if
-  </td>
-  <!--
-  <td>
-#if "endian" in $md
-  $md.endian
-#else
-  &nbsp;
-#end if
-  </td>
-  -->
-  </tr>
-#end for
-  </table>
-#end if
-#if $pkg.isalist
-  <h2>isalist</h2>
-  <ul class="code">
-#for isa in $pkg.isalist
-	  <li>
-	    $isa
-	  </li>
-#end for
-  </ul>
-#end if
-#if $pkg.mtime
-  <h2>mtime</h2>
-  <p>
-  $pkg.mtime
-  </p>
-#end if
-#if $pkg.overrides
-  <h2>overrides</h2>
-  <ul>
-#for override in $pkg.overrides
-  <li>
-  $override.pkgname
-  $override.tag_name
-  $override.tag_info
-  </li>
-#end for
-  </ul>
-#end if
-  <h2>pkgchk</h2>
-  <p>stdout</p>
-  <pre>
-#for l in $pkg.pkgchk.stdout_lines
-$l
-#end for
-  </pre>
-  <p>stderr</p>
-  <pre>
-#for l in $pkg.pkgchk.stderr_lines
-$l
-#end for
-  </pre>
-  <h2>pkgmap</h2>
-  <ul class="code">
-#for entry in $pkg.pkgmap
-  <li>
-  $entry.line
-  </li>
-#end for
-  </ul>
-#end for
-</body>
-</html>
-"""
-
 def GetPkg(some_id):
   logging.debug("Selecting from db: %s", repr(some_id))
   res = m.Srv4FileStats.select(
@@ -399,7 +109,14 @@
         build_src = None
       data["build_src"] = build_src
       pkgstats.append(data)
-    t = Template(REVIEW_REQ_TMPL, searchList=[{
+    # This assumes the program is run as "bin/pkgdb", and not "lib/python/pkgdb.py".
+    tmpl_filename = os.path.join(os.path.split(__file__)[0],
+                                 "..",
+                                 "lib",
+                                 "python",
+                                 "pkg-review-template.html")
+    tmpl_str = open(tmpl_filename, "r").read()
+    t = Template(tmpl_str, searchList=[{
       "pkgstats": pkgstats,
       "hachoir_machines": package_checks.HACHOIR_MACHINES,
       }])


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list