Base-Art - Utilshttps://base-art.net/2005-08-10T10:26:43+02:00SubveRSSed 1.02005-04-26T12:52:22+02:002005-08-10T10:26:43+02:00Philippe Normandtag:base-art.net,2005-04-26:/Articles/46/<p>I previously introduced a Subversion <a class="reference external" href="http://base-art.net/wk/Article/18.html">post-commit hook</a> to generate <span class="caps">RSS</span> feeds based on commits. But the generated feeds were not that smart. <a class="reference external" href="http://svn.pythonfr.org/public/pythonfr/utils/subversion/subverssed.py">SubveRSSed</a> 1.0 now handle <span class="caps">RSS</span> 1.0 feeds ! The next step will probably be Atom.</p>
<p><strong>update (05/08/10)</strong> : SubveRSSed 1.1 has a great speed improvement …</p><p>I previously introduced a Subversion <a class="reference external" href="http://base-art.net/wk/Article/18.html">post-commit hook</a> to generate <span class="caps">RSS</span> feeds based on commits. But the generated feeds were not that smart. <a class="reference external" href="http://svn.pythonfr.org/public/pythonfr/utils/subversion/subverssed.py">SubveRSSed</a> 1.0 now handle <span class="caps">RSS</span> 1.0 feeds ! The next step will probably be Atom.</p>
<p><strong>update (05/08/10)</strong> : SubveRSSed 1.1 has a great speed improvement since i dropped the “full <span class="caps">RSS</span> feed” support.</p>
Cheetah templates overriding2005-03-22T09:01:25+01:002005-05-30T22:04:27+02:00Philippe Normandtag:base-art.net,2005-03-22:/Articles/44/<p><a class="reference external" href="http://cheetahtemplate.org/">Cheetah</a> is a very good templating language, especially because it’s
the one (correct me if i’m wrong) to apply the Object-Oriented model
to Documents. It can seem a bit weird at the beginning but when you get
used to it, you can’t live without it :-)</p>
<p>So, i …</p><p><a class="reference external" href="http://cheetahtemplate.org/">Cheetah</a> is a very good templating language, especially because it’s
the one (correct me if i’m wrong) to apply the Object-Oriented model
to Documents. It can seem a bit weird at the beginning but when you get
used to it, you can’t live without it :-)</p>
<p>So, i was looking for a good way to overload template parts without
pain, here is how (couldn’t find the trick on Cheetah doc):</p>
<ol class="arabic">
<li><p class="first">Assume you have a template <tt class="docutils literal">Package/Page.tmpl</tt> like that:</p>
<pre class="literal-block">
#def footer
This is my foot !
#end def
</pre>
</li>
<li><p class="first">Create a <tt class="docutils literal">Page_custom.tmpl</tt> template:</p>
<pre class="literal-block">
#extends Package.Page
#def footer
$Page.footer($self) Where's my mind ? (dixit the Pixies)
#end def
</pre>
</li>
<li><p class="first">You need to put a <tt class="docutils literal">self</tt> variable in the template’s searchList
which is the Cheetah template instance itself :-)</p>
</li>
</ol>
<p>I don’t think that trick will work if you don’t compile your templates
to Python code.</p>
EFL tools in Python ?2005-03-10T11:17:16+01:002005-05-30T22:04:49+02:00Philippe Normandtag:base-art.net,2005-03-10:/Articles/42/<p>Just noticed an <a class="reference external" href="http://code-monkey.de/code/anEdjeCompilerInRuby.html">edje compiler in Ruby</a>. That’d be fun to design graphical E17 stuff in Python too :-)</p>
Inserting legend in images using PIL2005-02-09T10:37:00+01:002005-05-30T22:06:18+02:00Philippe Normandtag:base-art.net,2005-02-09:/Articles/30/<p>I wanted to insert legends directly in images instead of displaying them below respective images. ImageMagick can do that (Text directive) but it’s not smart enough to make the legend <em>always</em> visible, even in dark images (if the legend color is black). So i used this <a class="reference external" href="http://svn.pythonfr.org/public/pythonfr/utils/misc/annotateImage.py">script</a> to accomplish …</p><p>I wanted to insert legends directly in images instead of displaying them below respective images. ImageMagick can do that (Text directive) but it’s not smart enough to make the legend <em>always</em> visible, even in dark images (if the legend color is black). So i used this <a class="reference external" href="http://svn.pythonfr.org/public/pythonfr/utils/misc/annotateImage.py">script</a> to accomplish that task. Legend is inserted at the bottom of the image, in a little black bordered box. Advice: use <a class="reference external" href="http://effbot.org/pil/pilfonts.zip">pilfonts</a> because default font is a bit small :-)</p>
<p>Here is a sample output:</p>
<img alt="" class="align-center" src="http://base-art.net/static/sample.png" />
progressCopy2004-12-19T18:07:54+01:002005-05-30T22:07:13+02:00Philippe Normandtag:base-art.net,2004-12-19:/Articles/26/<p>I use to deal with large files under the console (copying iso images, videos) but cp doesn’t display much informations. Few days ago i read <a class="reference external" href="http://www.mechanicalcat.net/richard/log/Python/Progress_display">a post from Richard Jones</a> who wrote a very nice iterator aimed to display <span class="caps">ETA</span> informations about tasks on the console. So, here comes …</p><p>I use to deal with large files under the console (copying iso images, videos) but cp doesn’t display much informations. Few days ago i read <a class="reference external" href="http://www.mechanicalcat.net/richard/log/Python/Progress_display">a post from Richard Jones</a> who wrote a very nice iterator aimed to display <span class="caps">ETA</span> informations about tasks on the console. So, here comes <a class="reference external" href="http://svn.pythonfr.org/public/pythonfr/utils/misc/progressCopy.py">progressCopy.py</a>.</p>
<p>Though it’s not as powerfull as <span class="caps">GNU</span> <span class="caps">CP</span>, it performs everyday tasks like copying, moving files or directories around with <span class="caps">ETA</span> informations :) Enjoy the console !</p>
Database replicata2004-10-06T12:40:29+02:002005-05-30T22:08:56+02:00Philippe Normandtag:base-art.net,2004-10-06:/Articles/20/<p>I’m having few issues with the db (sqlite powered) behind this blog. So it’s necessary to migrate it to another <span class="caps">DBMS</span> (like PostgreSQL). The problem is that SQLite is a bit too light :) Fortunately, <a class="reference external" href="http://base-art.net/wk/Article/4.html">Alinea</a> is using <a class="reference external" href="http://sqlobject.org">SQLObject</a> to manage its database. So migration is trivial and can …</p><p>I’m having few issues with the db (sqlite powered) behind this blog. So it’s necessary to migrate it to another <span class="caps">DBMS</span> (like PostgreSQL). The problem is that SQLite is a bit too light :) Fortunately, <a class="reference external" href="http://base-art.net/wk/Article/4.html">Alinea</a> is using <a class="reference external" href="http://sqlobject.org">SQLObject</a> to manage its database. So migration is trivial and can be done using a little <a class="reference external" href="http://svn.pythonfr.org/public/alinea/tools/DBCo.py">script</a> which takes two db URIs and handle the data replication from a db to another.</p>
Bringing RSS to SVN2004-09-17T09:05:01+02:002005-05-30T22:09:27+02:00Philippe Normandtag:base-art.net,2004-09-17:/Articles/18/<p>About one week ago, Aaron Brady posted a svnstatus.py script which
displays an <span class="caps">SVN</span> repository version history in an <span class="caps">HTML</span> document. I
liked it and wanted to use it as a post-commit hook script for the
<a class="reference external" href="http://xmlobject.base-art.net">XMLObject</a> <span class="caps">SVN</span> repository. But svnstatus is not optimal at all. If you
want …</p><p>About one week ago, Aaron Brady posted a svnstatus.py script which
displays an <span class="caps">SVN</span> repository version history in an <span class="caps">HTML</span> document. I
liked it and wanted to use it as a post-commit hook script for the
<a class="reference external" href="http://xmlobject.base-art.net">XMLObject</a> <span class="caps">SVN</span> repository. But svnstatus is not optimal at all. If you
want to periodically build a static <span class="caps">HTML</span> file it’s ok. The problem, if
you want to use it in post-commit hook is that it rebuilds the file
for each commit, which turns to be really <span class="caps">CPU</span> hungry.</p>
<p>That’s why i wrote <a class="reference external" href="http://svn.pythonfr.org/public/pythonfr/utils/subversion/subverssed.py">SubveRSSed.py</a>. SubveRSSed incrementally builds an
<span class="caps">RSS</span> feed containing the commit history of a <span class="caps">SVN</span> Repository. Then an
<span class="caps">HTML</span> document is built based upon the <span class="caps">RSS</span> feed. This approach has many advantages:</p>
<ul class="simple">
<li>post-commit hook friendly :)</li>
<li>the <span class="caps">RSS</span> can be made available for aggregators and people can monitor
the activity/vitality of a repository</li>
<li>the history can still be consulted via the <span class="caps">HTML</span> document, if you
don’t like aggregators nor <span class="caps">RSS</span> ;)</li>
</ul>
<p>But there is one issue thought, the <span class="caps">RSS</span> accumulates all revisions, so it can grow enormously. I think i’ll make 2 feeds, one complete and one with the 20 latest revisions .. So SubverRSSed will evolve, may be in the <a class="reference external" href="http://svn.pythonfr.org/">PythonFR</a> <span class="caps">SVN</span> repository :-)</p>
<p><span class="caps">BTW</span>, many thanks to Aaron for svnstatus from which SubveRSSed used
some functions and embedded <span class="caps">CSS</span>.</p>
<p><strong>update</strong>: the script now handles 2 <span class="caps">RSS</span> feeds as described above :)</p>
<p><strong>update2</strong> : check out SubveRSSed at this <a class="reference external" href="http://svn.pythonfr.org/public/pythonfr/utils/subversion/subverssed.py">url</a></p>
<p><strong>update3(2005/05/05)</strong> : There’s a more recent <a class="reference external" href="http://base-art.net/Articles/46/">post</a> about this script.</p>
When IMAP lags with big folders2004-04-17T20:50:12+02:002005-05-30T22:03:36+02:00Philippe Normandtag:base-art.net,2004-04-17:/Articles/3/<p>I’m using mutt to read my mail through IMAP4_SSL… But currently it lacks of a cache system, so dealing with big folders (~2000) is quite hard for it.</p>
<p>That’s why I hacked an archive utility script to better fit with my needs. The original one is <a class="reference external" href="http://gray.mine.nu/maildirarchive/mdirarchive-0.1.py">here</a>. The …</p><p>I’m using mutt to read my mail through IMAP4_SSL… But currently it lacks of a cache system, so dealing with big folders (~2000) is quite hard for it.</p>
<p>That’s why I hacked an archive utility script to better fit with my needs. The original one is <a class="reference external" href="http://gray.mine.nu/maildirarchive/mdirarchive-0.1.py">here</a>. The purpose is to move old mails on subtrees of the folder we want to archive, sorted by month.</p>
<p>I mainly added an option relating mail dates comparisons. So now there are two possibilities :</p>
<ul class="simple">
<li>believe <span class="caps">IMAP</span> dates (appearing as timestamps in beginning of mail filenames) (default behavior)</li>
<li>believe <cite>Date:</cite> Mail header (-m option)</li>
</ul>
<p>Use-case :)</p>
<pre class="literal-block">
$ ./mdirarchive.py -m respyre
$ tree ~/Maildir/.respyre* -L 1
/home/phil/Maildir/.respyre
|-- courierimapacl
|-- courierimapkeywords
|-- courierimapuiddb
|-- cur
|-- new
`-- tmp
/home/phil/Maildir/.respyre.2003-06
|-- cur
|-- new
`-- tmp
/home/phil/Maildir/.respyre.2003-09
|-- cur
|-- new
`-- tmp
/home/phil/Maildir/.respyre.2003-10
|-- cur
|-- new
`-- tmp
</pre>
<p>There is now a subfolder per month. Check script online help for more options.</p>
<p><a class="reference external" href="/static/mdirarchive.py">Download</a></p>