You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
britney2-ubuntu/doc/html/excuse_8py-source.html

164 lines
17 KiB

<!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.7 -->
<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>00051 self.mindays = <span class="keywordtype">None</span>
<a name="l00052"></a>00052 self.section = <span class="keywordtype">None</span>
<a name="l00053"></a><a class="code" href="classexcuse_1_1Excuse.html#b8751fc5d0033b4c734c476d92841d99">00053</a> self.dontinvalidate = 0
<a name="l00054"></a>00054
<a name="l00055"></a>00055 self.invalid_deps = []
<a name="l00056"></a>00056 self.deps = []
<a name="l00057"></a>00057 self.sane_deps = []
<a name="l00058"></a><a class="code" href="classexcuse_1_1Excuse.html#189ec1709eef0bd8acb9cd093b8350b5">00058</a> self.break_deps = []
<a name="l00059"></a>00059 self.unsat_deps = {}
<a name="l00060"></a>00060 self.bugs = []
<a name="l00061"></a>00061 self.htmlline = []
<a name="l00062"></a><a class="code" href="classexcuse_1_1Excuse.html#6b435fa4d19b929d9fb70c8d28688387">00062</a>
<a name="l00063"></a>00063 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#b8751fc5d0033b4c734c476d92841d99">set_vers</a>(self, tver, uver):
<a name="l00064"></a>00064 <span class="stringliteral">"""Set the testing and unstable versions"""</span>
<a name="l00065"></a>00065 <span class="keywordflow">if</span> tver: self.ver = (tver, self.ver[1])
<a name="l00066"></a><a class="code" href="classexcuse_1_1Excuse.html#3a0ebe3eb87c1af8f093e80a874ea0fa">00066</a> <span class="keywordflow">if</span> uver: self.ver = (self.ver[0], uver)
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#189ec1709eef0bd8acb9cd093b8350b5">set_maint</a>(self, maint):
<a name="l00069"></a>00069 <span class="stringliteral">"""Set the package maintainer's name"""</span>
<a name="l00070"></a><a class="code" href="classexcuse_1_1Excuse.html#ac01c3b9802ad26571f01b55ffc1098c">00070</a> self.maint = self.<a class="code" href="classexcuse_1_1Excuse.html#bb15f55eed8f034db8a64b4ddc46460d">reemail</a>.sub(<span class="stringliteral">""</span>, maint)
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#6b435fa4d19b929d9fb70c8d28688387">set_section</a>(self, section):
<a name="l00073"></a>00073 <span class="stringliteral">"""Set the section of the package"""</span>
<a name="l00074"></a><a class="code" href="classexcuse_1_1Excuse.html#c504d40ac6d07ffdb08b7ff8ed555d10">00074</a> self.section = section
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#3a0ebe3eb87c1af8f093e80a874ea0fa">set_priority</a>(self, pri):
<a name="l00077"></a>00077 <span class="stringliteral">"""Set the priority of the package"""</span>
<a name="l00078"></a><a class="code" href="classexcuse_1_1Excuse.html#fa97c9f61fef17d6028491362153a766">00078</a> self.pri = pri
<a name="l00079"></a>00079
<a name="l00080"></a>00080 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#ac01c3b9802ad26571f01b55ffc1098c">set_date</a>(self, date):
<a name="l00081"></a>00081 <span class="stringliteral">"""Set the date of upload of the package"""</span>
<a name="l00082"></a><a class="code" href="classexcuse_1_1Excuse.html#8a89f54df8036e6f5c7c6bfa3f0cc6fc">00082</a> self.date = date
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#c504d40ac6d07ffdb08b7ff8ed555d10">set_urgency</a>(self, date):
<a name="l00085"></a>00085 <span class="stringliteral">"""Set the urgency of upload of the package"""</span>
<a name="l00086"></a><a class="code" href="classexcuse_1_1Excuse.html#60e00fe0515f2dab003bd29baceedd34">00086</a> self.urgency = date
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#fa97c9f61fef17d6028491362153a766">add_dep</a>(self, name):
<a name="l00089"></a>00089 <span class="stringliteral">"""Add a dependency"""</span>
<a name="l00090"></a>00090 <span class="keywordflow">if</span> name <span class="keywordflow">not</span> <span class="keywordflow">in</span> self.deps: self.deps.append(name)
<a name="l00091"></a><a class="code" href="classexcuse_1_1Excuse.html#7c76b47749dc3da2b1988a6991664a40">00091</a>
<a name="l00092"></a>00092 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#8a89f54df8036e6f5c7c6bfa3f0cc6fc">add_sane_dep</a>(self, name):
<a name="l00093"></a>00093 <span class="stringliteral">"""Add a sane dependency"""</span>
<a name="l00094"></a>00094 <span class="keywordflow">if</span> name <span class="keywordflow">not</span> <span class="keywordflow">in</span> self.sane_deps: self.sane_deps.append(name)
<a name="l00095"></a><a class="code" href="classexcuse_1_1Excuse.html#8594c46ccf4182fa8b37fe487bf53850">00095</a>
<a name="l00096"></a>00096 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#60e00fe0515f2dab003bd29baceedd34">add_break_dep</a>(self, name, arch):
<a name="l00097"></a>00097 <span class="stringliteral">"""Add a break dependency"""</span>
<a name="l00098"></a>00098 <span class="keywordflow">if</span> (name, arch) <span class="keywordflow">not</span> <span class="keywordflow">in</span> self.break_deps:
<a name="l00099"></a><a class="code" href="classexcuse_1_1Excuse.html#cf1fa7c6fb741bbe7e3120113748f3a5">00099</a> self.break_deps.append( (name, arch) )
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#7c76b47749dc3da2b1988a6991664a40">add_unsat_dep</a>(self, arch):
<a name="l00102"></a>00102 <span class="stringliteral">"""Add a flag for unsatisfied dependencies"""</span>
<a name="l00103"></a>00103 self.unsat_deps[arch] = <span class="keyword">True</span>
<a name="l00104"></a><a class="code" href="classexcuse_1_1Excuse.html#eb0a1ea0fae66a571e5efa703e53ba3a">00104</a>
<a name="l00105"></a>00105 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#8594c46ccf4182fa8b37fe487bf53850">invalidate_dep</a>(self, name):
<a name="l00106"></a>00106 <span class="stringliteral">"""Invalidate dependency"""</span>
<a name="l00107"></a>00107 <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="l00108"></a><a class="code" href="classexcuse_1_1Excuse.html#84049740652a58b248fabdb3fa9d4b2c">00108</a>
<a name="l00109"></a>00109 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#cf1fa7c6fb741bbe7e3120113748f3a5">setdaysold</a>(self, daysold, mindays):
<a name="l00110"></a>00110 <span class="stringliteral">"""Set the number of days from the upload and the minimum number of days for the update"""</span>
<a name="l00111"></a>00111 self.daysold = daysold
<a name="l00112"></a>00112 self.mindays = mindays
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#eb0a1ea0fae66a571e5efa703e53ba3a">addhtml</a>(self, note):
<a name="l00115"></a>00115 <span class="stringliteral">"""Add a note in HTML"""</span>
<a name="l00116"></a>00116 self.htmlline.append(note)
<a name="l00117"></a>00117
<a name="l00118"></a>00118 <span class="keyword">def </span><a class="code" href="classexcuse_1_1Excuse.html#84049740652a58b248fabdb3fa9d4b2c">html</a>(self):
<a name="l00119"></a>00119 <span class="stringliteral">"""Render the excuse in HTML"""</span>
<a name="l00120"></a>00120 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="l00121"></a>00121 (self.name, self.name, self.name, self.ver[0], self.ver[1])
<a name="l00122"></a>00122 <span class="keywordflow">if</span> self.maint:
<a name="l00123"></a>00123 res = res + <span class="stringliteral">"&lt;li&gt;Maintainer: %s\n"</span> % (self.maint)
<a name="l00124"></a>00124 <span class="keywordflow">if</span> self.section <span class="keywordflow">and</span> string.find(self.section, <span class="stringliteral">"/"</span>) &gt; -1:
<a name="l00125"></a>00125 res = res + <span class="stringliteral">"&lt;li&gt;Section: %s\n"</span> % (self.section)
<a name="l00126"></a>00126 <span class="keywordflow">if</span> self.daysold != <span class="keywordtype">None</span>:
<a name="l00127"></a>00127 <span class="keywordflow">if</span> self.daysold &lt; self.mindays:
<a name="l00128"></a>00128 res = res + (<span class="stringliteral">"&lt;li&gt;Too young, only %d of %d days old\n"</span> %
<a name="l00129"></a>00129 (self.daysold, self.mindays))
<a name="l00130"></a>00130 <span class="keywordflow">else</span>:
<a name="l00131"></a>00131 res = res + (<span class="stringliteral">"&lt;li&gt;%d days old (needed %d days)\n"</span> %
<a name="l00132"></a>00132 (self.daysold, self.mindays))
<a name="l00133"></a>00133 <span class="keywordflow">for</span> x <span class="keywordflow">in</span> self.htmlline:
<a name="l00134"></a>00134 res = res + <span class="stringliteral">"&lt;li&gt;"</span> + x + <span class="stringliteral">"\n"</span>
<a name="l00135"></a>00135 <span class="keywordflow">for</span> x <span class="keywordflow">in</span> self.deps:
<a name="l00136"></a>00136 <span class="keywordflow">if</span> x <span class="keywordflow">in</span> self.invalid_deps:
<a name="l00137"></a>00137 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="l00138"></a>00138 <span class="keywordflow">else</span>:
<a name="l00139"></a>00139 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="l00140"></a>00140 <span class="keywordflow">for</span> (n,a) <span class="keywordflow">in</span> self.break_deps:
<a name="l00141"></a>00141 <span class="keywordflow">if</span> n <span class="keywordflow">not</span> <span class="keywordflow">in</span> self.deps:
<a name="l00142"></a>00142 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="l00143"></a>00143 res = res + <span class="stringliteral">"&lt;/ul&gt;\n"</span>
<a name="l00144"></a>00144 <span class="keywordflow">return</span> res
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Aug 18 23:23:25 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.7 </small></address>
</body>
</html>