britney2-ubuntu/doc/html/excuse_8py-source.html
Fabio Tranchitella f7b9bdc1f4 Support for fake source packages, which solved the last compatibility issues for the old britney code.
Added documentation and comments to explain the code. It is possible to generate HTML and LaTeX documentation using doxygen.
2006-06-24 17:49:43 +00:00

154 lines
15 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>briteny: excuse.py Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="namespaces.html"><span>Packages</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li id="current"><a href="files.html"><span>Files</span></a></li>
</ul></div>
<h1>excuse.py</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="namespaceexcuse.html">00001</a> <span class="comment"># -*- coding: utf-8 -*-</span>
<a name="l00002"></a>00002
<a name="l00003"></a>00003 <span class="comment"># Copyright (C) 2001-2004 Anthony Towns &lt;ajt@debian.org&gt;</span>
<a name="l00004"></a>00004 <span class="comment"># Andreas Barth &lt;aba@debian.org&gt;</span>
<a name="l00005"></a>00005 <span class="comment"># Fabio Tranchitella &lt;kobold@debian.org&gt;</span>
<a name="l00006"></a>00006
<a name="l00007"></a>00007 <span class="comment"># This program is free software; you can redistribute it and/or modify</span>
<a name="l00008"></a>00008 <span class="comment"># it under the terms of the GNU General Public License as published by</span>
<a name="l00009"></a>00009 <span class="comment"># the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00010"></a>00010 <span class="comment"># (at your option) any later version.</span>
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="comment"># This program is distributed in the hope that it will be useful,</span>
<a name="l00013"></a>00013 <span class="comment"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00014"></a>00014 <span class="comment"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00015"></a>00015 <span class="comment"># GNU General Public License for more details.</span>
<a name="l00016"></a>00016
<a name="l00017"></a>00017 <span class="keyword">import</span> re
<a name="l00018"></a>00018 <span class="keyword">import</span> string
<a name="l00019"></a>00019
<a name="l00020"></a>00020
<a name="l00021"></a><a class="code" href="classexcuse_1_1Excuse.html">00021</a> <span class="keyword">class </span><a class="code" href="classexcuse_1_1Excuse.html">Excuse</a>:
<a name="l00022"></a>00022 <span class="stringliteral">"""Excuse class</span>
<a name="l00023"></a>00023 <span class="stringliteral"> </span>
<a name="l00024"></a>00024 <span class="stringliteral"> This class represents an update excuse, which is a detailed explanation</span>
<a name="l00025"></a>00025 <span class="stringliteral"> of why a package can or cannot be updated in the testing distribution from</span>
<a name="l00026"></a><a class="code" href="classexcuse_1_1Excuse.html#bb15f55eed8f034db8a64b4ddc46460d">00026</a> <span class="stringliteral"> a newer package in another distribution (like for example unstable).</span>
<a name="l00027"></a>00027 <span class="stringliteral"></span>
<a name="l00028"></a><a class="code" href="classexcuse_1_1Excuse.html#4bdb0917f763d74951c621e466e98bdb">00028</a> <span class="stringliteral"> The main purpose of the excuses is to be written in an HTML file which</span>
<a name="l00029"></a>00029 <span class="stringliteral"> will be published over HTTP. The maintainers will be able to parse it</span>
<a name="l00030"></a>00030 <span class="stringliteral"> manually or automatically to find the explanation of why their packages</span>
<a name="l00031"></a>00031 <span class="stringliteral"> have been updated or not.</span>
<a name="l00032"></a>00032 <span class="stringliteral"> """</span>
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="comment">## @var reemail</span>
<a name="l00035"></a>00035 <span class="comment"># Regular expression for removing the email address</span>
<a name="l00036"></a>00036 reemail = re.compile(<span class="stringliteral">r"&lt;.*?&gt;"</span>)
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#4bdb0917f763d74951c621e466e98bdb">__init__</a>(self, name):
<a name="l00039"></a>00039 <span class="stringliteral">"""Class constructor</span>
<a name="l00040"></a>00040 <span class="stringliteral"> </span>
<a name="l00041"></a>00041 <span class="stringliteral"> This method initializes the excuse with the specified name and</span>
<a name="l00042"></a>00042 <span class="stringliteral"> the default values.</span>
<a name="l00043"></a>00043 <span class="stringliteral"> """</span>
<a name="l00044"></a>00044 self.name = name
<a name="l00045"></a>00045 self.ver = (<span class="stringliteral">"-"</span>, <span class="stringliteral">"-"</span>)
<a name="l00046"></a>00046 self.maint = <span class="keywordtype">None</span>
<a name="l00047"></a>00047 self.pri = <span class="keywordtype">None</span>
<a name="l00048"></a>00048 self.date = <span class="keywordtype">None</span>
<a name="l00049"></a>00049 self.urgency = <span class="keywordtype">None</span>
<a name="l00050"></a>00050 self.daysold = <span class="keywordtype">None</span>
<a name="l00051"></a><a class="code" href="classexcuse_1_1Excuse.html#b8751fc5d0033b4c734c476d92841d99">00051</a> self.mindays = <span class="keywordtype">None</span>
<a name="l00052"></a>00052 self.section = <span class="keywordtype">None</span>
<a name="l00053"></a>00053 self.dontinvalidate = 0
<a name="l00054"></a>00054
<a name="l00055"></a>00055 self.invalid_deps = []
<a name="l00056"></a><a class="code" href="classexcuse_1_1Excuse.html#189ec1709eef0bd8acb9cd093b8350b5">00056</a> self.deps = []
<a name="l00057"></a>00057 self.break_deps = []
<a name="l00058"></a>00058 self.bugs = []
<a name="l00059"></a>00059 self.htmlline = []
<a name="l00060"></a><a class="code" href="classexcuse_1_1Excuse.html#6b435fa4d19b929d9fb70c8d28688387">00060</a>
<a name="l00061"></a>00061 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#b8751fc5d0033b4c734c476d92841d99">set_vers</a>(self, tver, uver):
<a name="l00062"></a>00062 <span class="stringliteral">"""Set the testing and unstable versions"""</span>
<a name="l00063"></a>00063 <span class="keywordflow">if</span> tver: self.ver = (tver, self.ver[1])
<a name="l00064"></a><a class="code" href="classexcuse_1_1Excuse.html#3a0ebe3eb87c1af8f093e80a874ea0fa">00064</a> <span class="keywordflow">if</span> uver: self.ver = (self.ver[0], uver)
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#189ec1709eef0bd8acb9cd093b8350b5">set_maint</a>(self, maint):
<a name="l00067"></a>00067 <span class="stringliteral">"""Set the package maintainer's name"""</span>
<a name="l00068"></a><a class="code" href="classexcuse_1_1Excuse.html#ac01c3b9802ad26571f01b55ffc1098c">00068</a> self.maint = self.<a class="code" href="classexcuse_1_1Excuse.html#bb15f55eed8f034db8a64b4ddc46460d">reemail</a>.sub(<span class="stringliteral">""</span>, maint)
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#6b435fa4d19b929d9fb70c8d28688387">set_section</a>(self, section):
<a name="l00071"></a>00071 <span class="stringliteral">"""Set the section of the package"""</span>
<a name="l00072"></a><a class="code" href="classexcuse_1_1Excuse.html#c504d40ac6d07ffdb08b7ff8ed555d10">00072</a> self.section = section
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#3a0ebe3eb87c1af8f093e80a874ea0fa">set_priority</a>(self, pri):
<a name="l00075"></a>00075 <span class="stringliteral">"""Set the priority of the package"""</span>
<a name="l00076"></a><a class="code" href="classexcuse_1_1Excuse.html#fa97c9f61fef17d6028491362153a766">00076</a> self.pri = pri
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#ac01c3b9802ad26571f01b55ffc1098c">set_date</a>(self, date):
<a name="l00079"></a>00079 <span class="stringliteral">"""Set the date of upload of the package"""</span>
<a name="l00080"></a><a class="code" href="classexcuse_1_1Excuse.html#60e00fe0515f2dab003bd29baceedd34">00080</a> self.date = date
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#c504d40ac6d07ffdb08b7ff8ed555d10">set_urgency</a>(self, date):
<a name="l00083"></a>00083 <span class="stringliteral">"""Set the urgency of upload of the package"""</span>
<a name="l00084"></a>00084 self.urgency = date
<a name="l00085"></a><a class="code" href="classexcuse_1_1Excuse.html#8594c46ccf4182fa8b37fe487bf53850">00085</a>
<a name="l00086"></a>00086 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#fa97c9f61fef17d6028491362153a766">add_dep</a>(self, name):
<a name="l00087"></a>00087 <span class="stringliteral">"""Add a dependency"""</span>
<a name="l00088"></a>00088 <span class="keywordflow">if</span> name <span class="keywordflow">not</span> <span class="keywordflow">in</span> self.deps: self.deps.append(name)
<a name="l00089"></a><a class="code" href="classexcuse_1_1Excuse.html#cf1fa7c6fb741bbe7e3120113748f3a5">00089</a>
<a name="l00090"></a>00090 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#60e00fe0515f2dab003bd29baceedd34">add_break_dep</a>(self, name, arch):
<a name="l00091"></a>00091 <span class="stringliteral">"""Add a break dependency"""</span>
<a name="l00092"></a>00092 <span class="keywordflow">if</span> (name, arch) <span class="keywordflow">not</span> <span class="keywordflow">in</span> self.break_deps:
<a name="l00093"></a>00093 self.break_deps.append( (name, arch) )
<a name="l00094"></a><a class="code" href="classexcuse_1_1Excuse.html#eb0a1ea0fae66a571e5efa703e53ba3a">00094</a>
<a name="l00095"></a>00095 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#8594c46ccf4182fa8b37fe487bf53850">invalidate_dep</a>(self, name):
<a name="l00096"></a>00096 <span class="stringliteral">"""Invalidate dependency"""</span>
<a name="l00097"></a>00097 <span class="keywordflow">if</span> name <span class="keywordflow">not</span> <span class="keywordflow">in</span> self.invalid_deps: self.invalid_deps.append(name)
<a name="l00098"></a><a class="code" href="classexcuse_1_1Excuse.html#84049740652a58b248fabdb3fa9d4b2c">00098</a>
<a name="l00099"></a>00099 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#cf1fa7c6fb741bbe7e3120113748f3a5">setdaysold</a>(self, daysold, mindays):
<a name="l00100"></a>00100 <span class="stringliteral">"""Set the number of days from the upload and the minimum number of days for the update"""</span>
<a name="l00101"></a>00101 self.daysold = daysold
<a name="l00102"></a>00102 self.mindays = mindays
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#eb0a1ea0fae66a571e5efa703e53ba3a">addhtml</a>(self, note):
<a name="l00105"></a>00105 <span class="stringliteral">"""Add a note in HTML"""</span>
<a name="l00106"></a>00106 self.htmlline.append(note)
<a name="l00107"></a>00107
<a name="l00108"></a>00108 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#84049740652a58b248fabdb3fa9d4b2c">html</a>(self):
<a name="l00109"></a>00109 <span class="stringliteral">"""Render the excuse in HTML"""</span>
<a name="l00110"></a>00110 res = <span class="stringliteral">"&lt;a id=\"%s\" name=\"%s\"&gt;%s&lt;/a&gt; (%s to %s)\n&lt;ul&gt;\n"</span> % \
<a name="l00111"></a>00111 (self.name, self.name, self.name, self.ver[0], self.ver[1])
<a name="l00112"></a>00112 <span class="keywordflow">if</span> self.maint:
<a name="l00113"></a>00113 res = res + <span class="stringliteral">"&lt;li&gt;Maintainer: %s\n"</span> % (self.maint)
<a name="l00114"></a>00114 <span class="keywordflow">if</span> self.section <span class="keywordflow">and</span> string.find(self.section, <span class="stringliteral">"/"</span>) &gt; -1:
<a name="l00115"></a>00115 res = res + <span class="stringliteral">"&lt;li&gt;Section: %s\n"</span> % (self.section)
<a name="l00116"></a>00116 <span class="keywordflow">if</span> self.daysold != <span class="keywordtype">None</span>:
<a name="l00117"></a>00117 <span class="keywordflow">if</span> self.daysold &lt; self.mindays:
<a name="l00118"></a>00118 res = res + (<span class="stringliteral">"&lt;li&gt;Too young, only %d of %d days old\n"</span> %
<a name="l00119"></a>00119 (self.daysold, self.mindays))
<a name="l00120"></a>00120 <span class="keywordflow">else</span>:
<a name="l00121"></a>00121 res = res + (<span class="stringliteral">"&lt;li&gt;%d days old (needed %d days)\n"</span> %
<a name="l00122"></a>00122 (self.daysold, self.mindays))
<a name="l00123"></a>00123 <span class="keywordflow">for</span> x <span class="keywordflow">in</span> self.htmlline:
<a name="l00124"></a>00124 res = res + <span class="stringliteral">"&lt;li&gt;"</span> + x + <span class="stringliteral">"\n"</span>
<a name="l00125"></a>00125 <span class="keywordflow">for</span> x <span class="keywordflow">in</span> self.deps:
<a name="l00126"></a>00126 <span class="keywordflow">if</span> x <span class="keywordflow">in</span> self.invalid_deps:
<a name="l00127"></a>00127 res = res + <span class="stringliteral">"&lt;li&gt;Depends: %s &lt;a href=\"#%s\"&gt;%s&lt;/a&gt; (not considered)\n"</span> % (self.name, x, x)
<a name="l00128"></a>00128 <span class="keywordflow">else</span>:
<a name="l00129"></a>00129 res = res + <span class="stringliteral">"&lt;li&gt;Depends: %s &lt;a href=\"#%s\"&gt;%s&lt;/a&gt;\n"</span> % (self.name, x, x)
<a name="l00130"></a>00130 <span class="keywordflow">for</span> (n,a) <span class="keywordflow">in</span> self.break_deps:
<a name="l00131"></a>00131 <span class="keywordflow">if</span> n <span class="keywordflow">not</span> <span class="keywordflow">in</span> self.deps:
<a name="l00132"></a>00132 res += <span class="stringliteral">"&lt;li&gt;Ignoring %s depends: &lt;a href=\"#%s\"&gt;%s&lt;/a&gt;\n"</span> % (a, n, n)
<a name="l00133"></a>00133 res = res + <span class="stringliteral">"&lt;/ul&gt;\n"</span>
<a name="l00134"></a>00134 <span class="keywordflow">return</span> res
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sat Jun 24 18:50:20 2006 for briteny by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>