archives/2009StyXman's globhttp://grulicueva.homelinux.net/~mdione/glob//archives/2009/StyXman's globikiwiki2009-11-20T16:42:58Zsatyr-0.1-beta1http://grulicueva.homelinux.net/~mdione/glob//posts/satyr-0.1-beta1/2009-11-20T16:42:58Z2009-11-20T00:38:21Z
<p>Today I sat down and tried to refactor <code>satyr</code> once
more after dinner. This time I was trying to decouple the
functionality related to multi-collection playlists from
<code>PlayListModel</code> while moving it to the
<code>default</code> skin. The idea was to be able to create
another skin which used a <code>QTableView</code>, which in turn
would be a trampoline for implementing tag editing and writing. But
I started to stall a little, and that normally provokes me to
defocus, to dezone. When that happens, I go and read some piled up
posts in <code>akregator</code>[1].</p>
<p>This time I came around <a href=
"http://www.cyrius.com/journal/fossbazaar/lessons-from-freedos">a
post by Martin Michlmayr</a> (who I read through <a href=
"http://planet.debian.org/">Planet Debian</a>) from 10 days ago
which talks about lessons learned about free software projects.
Actually the post is just a resume of 4 posts from the FreeDOS
founder Jim Hall. At some point he writes «releases are
important».</p>
<p><strong>Bing!</strong> goes my head[2]. <code>satyr</code> is
already 3 months, 12 days or 117 revisions old and I hadn't
released it yet, even after I promissed to do so almost a month
ago! The problem is that I kept adding features (and squashing bugs
in <code>Phonon</code>[3]) and completely forgot about releasing.
Just one semi-colon before he also writes «initial users of the
software should be recruited as developers»... which users? If one
doesn't release, one might never have users to recruit!</p>
<p>So instead of the pharaonic refactor I had in mind (an in
another branch, blessed be <code>bazaar</code>) I wrote a
<code>setup.py</code> script in 15 minutes, massaged a little the
files (I had to create a package and modify almost all the files to
reflect this), tested a little, and produced a nice triplet of
files:</p>
<pre>
<code>satyr-0.1-beta1.tar.bz2
satyr-0.1-beta1.tar.gz
satyr-0.1-beta1.zip
</code>
</pre>
<p>So there you have it, a realease! Ok, it's a 'beta1', but it's
out. Go grab it, test it, complain about bugs, tell us you like it,
suggest improvements, whatever! And tell your best friend to use
it, even if you don't like it! Where to get it? Why, from <a href=
"http://mirrors.aixtools.net/sv/satyr/">the project's download's
page</a>, of course!</p>
<hr />
<p><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/satyr/">satyr</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/pykde/">pykde</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/python/">python</a></p>
<hr />
<p>[1] Yes, once upon a time I developed my own feed reader called
<code>kReiSSy</code>, but it's implemented in <code>PyKDE3</code>
and I don't plan to port it yet, even if somehow is better for me
than <code>akregator</code>. A shame, reallly...</p>
<p>[2] in the same way that a µ-wave oven goes “bing”, not in an
“Eureka!” way...</p>
<p>[3] I even fixed the need for the 'file' scheme in the Gstreamer
backend.</p>
qlistmodel-in-pyqthttp://grulicueva.homelinux.net/~mdione/glob//posts/qlistmodel-in-pyqt/2009-11-19T00:28:01Z2009-11-19T00:28:01Z
<p>One of the things I had to while developing <code>satyr</code>
is building a model for a <code>QListViewer</code>. It should be
straighforward from qt's documentation, but I found a couple of
things that I would like to put in a post, specially because there
doesn't seem to be much models in <code>PyQt4</code> easily found
in the web.</p>
<p>According to its description, a subclass of
<code>QAbstractListModel</code> as this one should mostly implement
the <code>data()</code> and <code>rowCount()</code> methods, which
is true. This example creates a read-only model, so no need to
implement <code>setData()</code>, but given the simplicity of
<code>data()</code>, it doesn't seem too difficult to do. I also
wanted it to react when more <code>Song</code>s were added on the
fly[1].</p>
<p>The method <code>data()</code> is the most important one. It is
not only used for retrieving the data itself, but also some
metadata useful for showing the data, like icons and other stuff.
For selecting what the caller wants, it refers a
<code>Qt.ItemDataRole</code>. The role for the data itself is
<code>Qt.DisplayRole</code>. One of the particularities of this
method is that it could be called with any vegetable as input;
namely, it can refer to a row that does not exist anymore or for
metadata that you don't care about. In those cases you must return
an empty <code>QVariant</code>, not <code>None</code>. So, a first
implementation is:</p>
<pre class="hl">
<span class="hl kwa">def</span> <span class=
"hl kwd">data</span> <span class="hl sym">(</span>self<span class=
"hl sym">,</span> modelIndex<span class=
"hl sym">,</span> role<span class="hl sym">):</span>
<span class="hl kwa">if</span> modelIndex<span class=
"hl sym">.</span><span class="hl kwd">isValid</span> <span class=
"hl sym">()</span> <span class=
"hl kwa">and</span> modelIndex<span class=
"hl sym">.</span><span class="hl kwd">row</span> <span class=
"hl sym">()<</span>self<span class=
"hl sym">.</span>count <span class=
"hl kwa">and</span> role<span class=
"hl sym">==</span>Qt<span class="hl sym">.</span>DisplayRole<span class="hl sym">:</span>
<span class=
"hl slc"># songForIndex() returns the Song corresponding to the row</span>
song<span class="hl sym">=</span> self<span class=
"hl sym">.</span><span class=
"hl kwd">songForIndex</span> <span class=
"hl sym">(</span>modelIndex<span class=
"hl sym">.</span><span class="hl kwd">row</span> <span class=
"hl sym">())</span>
<span class=
"hl slc"># formatSong() returns a QString with the data to show</span>
data<span class="hl sym">=</span> <span class=
"hl kwd">QVariant</span> <span class=
"hl sym">(</span>self<span class="hl sym">.</span><span class=
"hl kwd">formatSong</span> <span class=
"hl sym">(</span>song<span class="hl sym">))</span>
<span class="hl kwa">else</span><span class="hl sym">:</span>
data<span class="hl sym">=</span> <span class=
"hl kwd">QVariant</span> <span class="hl sym">()</span>
<span class="hl kwa">return</span> data
</pre>
<p>This method, together with a <code>rowCount()</code> that simply
returns <code>self.count</code>, is enough for showing data that is
already there. Notice that the <code>QModelIndex</code> can be not
valid, and in this case we only care about its row because we're a
list.</p>
<p>But then I wanted my <code>QListViewer</code> to show songs
progresively as they are loaded/scanned[2] and also as they are
found as new. But then a problem arises: the view is like a table
of only one column. The width of this colunm at the begining is the
same width as the <code>QListView</code> itself. But what happens
when the string shown is too big? What happens is that it gets
chopped. We must inform the view that some of the rows are bigger.
That's where the metadata comes into play.</p>
<p>Another possible role is <code>Qt.SizeHintRole</code>. If we
return a size instead of an empty <code>QVariant</code>, that size
will be used to expand the column as needed, even giving us a
scrollbar if it's wider that the view.</p>
<p>Now, we're supposed to show the tags for the <code>Song</code>
(that's what <code>formatSong()</code> does if possible; if not, it
simply returns the filepath), so this width should be calculated
based on the length of the string that represents the song[3]. But
if we try to read the tags for all the songs as we load the
<code>Collection</code>, we end up with too much disk activity
before you can show anything to the user, which is unacceptable[4].
So instead we calculate based on the filepath, which is used for
<code>Songs</code> with too few tags anyways. Here's the hacky
code:</p>
<pre class="hl">
<span class="hl sym">...</span>
<span class="hl slc"># FIXME: kinda hacky</span>
self<span class="hl sym">.</span>fontMetrics<span class=
"hl sym">=</span> <span class=
"hl kwd">QFontMetrics</span> <span class=
"hl sym">(</span>KGlobalSettings<span class=
"hl sym">.</span><span class=
"hl kwd">generalFont</span> <span class="hl sym">())</span>
<span class="hl sym">...</span>
<span class="hl kwa">def</span> <span class=
"hl kwd">data</span> <span class="hl sym">(</span>self<span class=
"hl sym">,</span> modelIndex<span class=
"hl sym">,</span> role<span class="hl sym">):</span>
<span class="hl kwa">if</span> modelIndex<span class=
"hl sym">.</span><span class="hl kwd">isValid</span> <span class=
"hl sym">()</span> <span class=
"hl kwa">and</span> modelIndex<span class=
"hl sym">.</span><span class="hl kwd">row</span> <span class=
"hl sym">()<</span>self<span class=
"hl sym">.</span>count<span class="hl sym">:</span>
song<span class="hl sym">=</span> self<span class=
"hl sym">.</span><span class=
"hl kwd">songForIndex</span> <span class=
"hl sym">(</span>modelIndex<span class=
"hl sym">.</span><span class="hl kwd">row</span> <span class=
"hl sym">())</span>
<span class="hl kwa">if</span> role<span class=
"hl sym">==</span>Qt<span class=
"hl sym">.</span>DisplayRole<span class="hl sym">:</span>
data<span class="hl sym">=</span> <span class=
"hl kwd">QVariant</span> <span class=
"hl sym">(</span>self<span class="hl sym">.</span><span class=
"hl kwd">formatSong</span> <span class=
"hl sym">(</span>song<span class="hl sym">))</span>
<span class="hl kwa">elif</span> role<span class=
"hl sym">==</span>Qt<span class=
"hl sym">.</span>SizeHintRole<span class="hl sym">:</span>
<span class=
"hl slc"># calculate something based on the filepath</span>
data<span class="hl sym">=</span> <span class=
"hl kwd">QVariant</span> <span class=
"hl sym">(</span>self<span class=
"hl sym">.</span>fontMetrics<span class=
"hl sym">.</span><span class="hl kwd">size</span> <span class=
"hl sym">(</span>Qt<span class=
"hl sym">.</span>TextSingleLine<span class=
"hl sym">,</span> song<span class=
"hl sym">.</span>filepath<span class="hl sym">))</span>
<span class="hl kwa">else</span><span class=
"hl sym">:</span>
data<span class="hl sym">=</span> <span class=
"hl kwd">QVariant</span> <span class="hl sym">()</span>
<span class="hl kwa">else</span><span class="hl sym">:</span>
data<span class="hl sym">=</span> <span class=
"hl kwd">QVariant</span> <span class="hl sym">()</span>
<span class="hl kwa">return</span> data
</pre>
<p>The last point then is reacting to <code>Song</code>s are added
on the fly. This is also easy: you tell the views you're about to
insert rows, you insert them, tell the views you finished, and then
emit <code>dataChanged()</code>:</p>
<pre class="hl">
<span class="hl kwa">def</span> <span class=
"hl kwd">addSong</span> <span class=
"hl sym">(</span>self<span class="hl sym">):</span>
<span class=
"hl slc"># lastIndex keeps track of the last index used.</span>
row<span class="hl sym">=</span> self<span class=
"hl sym">.</span>lastIndex
self<span class="hl sym">.</span>lastIndex<span class=
"hl sym">+=</span> <span class="hl num">1</span>
self<span class="hl sym">.</span><span class=
"hl kwd">beginInsertRows</span> <span class=
"hl sym">(</span><span class=
"hl kwd">QModelIndex</span> <span class=
"hl sym">(),</span> row<span class=
"hl sym">,</span> row<span class="hl sym">)</span>
<span class=
"hl slc"># actually the Song has already been added to the Collection[5]</span>
<span class="hl slc"># so I don't do anything here,</span>
<span class=
"hl slc"># but if you keep your rows in this model you should do something here</span>
self<span class="hl sym">.</span><span class=
"hl kwd">endInsertRows</span> <span class="hl sym">()</span>
self<span class="hl sym">.</span>count<span class=
"hl sym">+=</span> <span class="hl num">1</span>
modelIndex<span class="hl sym">=</span> self<span class=
"hl sym">.</span><span class="hl kwd">index</span> <span class=
"hl sym">(</span>row<span class="hl sym">,</span> <span class=
"hl num">0</span><span class="hl sym">)</span>
self<span class="hl sym">.</span>dataChanged<span class=
"hl sym">.</span><span class="hl kwd">emit</span> <span class=
"hl sym">(</span>modelIndex<span class=
"hl sym">,</span> modelIndex<span class="hl sym">)</span>
</pre>
<p>Later I'll post any peculiarities I find porting all this stuff
to a read/write <code>QTableModel</code>.</p>
<hr />
<p><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/satyr/">satyr</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/pykde/">pykde</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/python/">python</a></p>
<hr />
<p>[1] That's material for another post :)</p>
<p>[2] This feature can be said to be a little too much. Actually,
I get a flicker when scanning.</p>
<p>[3] Of course the next step is to use a table view and make a
model for it.</p>
<p>[4] Right now the load time for a <code>Collection</code> of
~6.5k songs is quite long as it is.</p>
<p>[5] This is a design decision which is not relevant to this
example.</p>
skinning-satyrhttp://grulicueva.homelinux.net/~mdione/glob//posts/skinning-satyr/2009-11-19T00:28:01Z2009-11-17T11:15:32Z
<p>One of the features I planned for <code>satyr</code> almost
since the begining was the possibility to have 'skins'. In this
context, a skin would not only implement the look and feel, but
also could implement features the weren't available in the shipped
classes. I also planned to implement this feature after I had most
of the others one already done. But then I was bored this weekend
with nothing to do and I decided to set off to at least investigate
how to do it. Of course, what happened was that I implemented it
almost completely.</p>
<p>Up to now, <code>satyr</code>'s user interface was implemented
in two files: <code>default.ui</code>, which was compiled with
<code>pyuic4</code> into <code>default.py</code>, and some code in
<code>satyr.py</code> itself. This of course would not scale, and I
always had the idea of moving the behaviour implemented in
<code>satyr.py</code> to a file called <code>default.py</code> and
load the ui directly from the <code>default.ui</code> file without
compiling, getting rid of the need for a compilation at the same
time. This also meant that then a skin would consist of a
<code>.py</code> file and possibly a <code>.ui</code> file. There
are three problems to solve for this: getting the
local-to-the-user's skin directory, loading the skin and loading
the correspondant <code>.ui</code> file.</p>
<p>The first part is simple from the <code>PyKDE4</code> point of
view:</p>
<pre class="hl">
<span class=
"hl slc"># get the app's dir; don't forget the trailing '/'!</span>
appDir<span class="hl sym">=</span> KStandardDirs<span class=
"hl sym">.</span><span class=
"hl kwd">locateLocal</span> <span class=
"hl sym">(</span><span class="hl str">'data'</span><span class=
"hl sym">,</span> <span class="hl str">'satyr/'</span><span class=
"hl sym">)</span>
</pre>
<p>I'll first explain the other two parts, loading the skin and the
<code>.ui</code> file, before returning more deeply to the
consequences of this solution.</p>
<p>I put all the skins in a <code>skins</code> subdirectory. To
make it a proper python module I added an empty
<code>__init__.py</code> file. Now, I could simply <code>import
skins.<skinName></code> and possibly instantiate some class
in it, but of course one cannot write that. I could resort to
<code>eval ('import skins.'+skinName)</code>, but we know that
<code>eval()</code> has the most long-standing typo in the history
of computer languages, and it's actually called
<code>evil()</code>.</p>
<p>What we can do is resort to <code>__import__()</code> instead.
This little function does approximately what we want. I say approx
because it has some surprises in the sleeves of its sleeveless
code. I suggest you to go read carefully its documentation.
Meanwhile, the magic itself:</p>
<pre class="hl">
mod<span class="hl sym">=</span> <span class=
"hl kwb">__import__</span> <span class=
"hl sym">(</span><span class="hl str">'skins.'</span><span class=
"hl sym">+</span>skinName<span class="hl sym">,</span> <span class=
"hl kwb">globals</span><span class="hl sym">(),</span> <span class=
"hl kwb">locals</span><span class="hl sym">(),</span> <span class=
"hl str">'MainWindow'</span><span class="hl sym">)</span>
mw<span class="hl sym">=</span> mod<span class=
"hl sym">.</span><span class=
"hl kwd">MainWindow</span> <span class="hl sym">()</span>
</pre>
<p>Loading the <code>.ui</code> file in the skin's code is rather
simple: just get the skin module's filepath, replace
<code>.py</code> with <code>.ui</code>, and load it with
<code>PyQt4.uic.loadUiType()</code>[1]. This function returns a
generated class for the topmost widget and its Qt base class. This
generated class has a <code>setupUi()</code> method that is the one
that actually builds de UI[2]. So, we just instantiate the main
window's class and call its <code>setupUi()</code> method:</p>
<pre class="hl">
<span class="hl kwa">from</span> PyQt4 <span class=
"hl kwa">import</span> uic
<span class="hl slc"># !!! __file__ might end with .py[co]!</span>
uipath<span class="hl sym">=</span> __file__<span class=
"hl sym">[:</span>__file__<span class="hl sym">.</span><span class=
"hl kwd">rfind</span> <span class="hl sym">(</span><span class=
"hl str">'.'</span><span class="hl sym">)]+</span><span class=
"hl str">'.ui'</span>
<span class="hl slc"># I don't care about the base class</span>
<span class="hl sym">(</span>UIMainWindow<span class=
"hl sym">,</span> buh<span class="hl sym">)=</span> uic<span class=
"hl sym">.</span><span class=
"hl kwd">loadUiType</span> <span class="hl sym">(</span>uipath<span class="hl sym">)</span>
self<span class="hl sym">.</span>ui<span class=
"hl sym">=</span> <span class=
"hl kwd">UIMainWindow</span> <span class="hl sym">()</span>
self<span class="hl sym">.</span>ui<span class=
"hl sym">.</span><span class="hl kwd">setupUi</span> <span class=
"hl sym">(</span>self<span class="hl sym">)</span>
</pre>
<p>Note the comment about the <code>__file__</code> attribute of a
module.</p>
<p>Now, and back to the first part, finding the local-to-the-user's
skin directory is the easiest part. From there, things get a little
bit more complicated:</p>
<ul>
<li>The <code>skins</code> subdirectory might not exist.</li>
<li>If you create it, you gotta make sure to also throw in a
<code>__init__.py</code> file.</li>
<li>Once you've done it, you also need to add the
local-to-the-user's app directory to the path. It's easy, just
prepend it to <code>sys.path</code>, so it's used before any
system-wide directory.</li>
<li>The last problem that remains is exactly that: once the
<code>__init__.py</code> is there and the user's dir is prepended
to <code>sys.path</code>, the user's local skin directory is always
used when importing anything from the <code>skins</code> module, so
if a skin is not there it is not loadable. All skins distributed
with <code>satyr</code> will be inaccesible!</li>
</ul>
<p>So I'm in a kind of dead alley here. I have a couple of ideas on
how to work-around this, but they're at best hacky, and I don't
want to implement them until I'm sure that it's inevitable.</p>
<hr />
<p><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/satyr/">satyr</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/pykde/">pykde</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/python/">python</a></p>
<hr />
<p>[1] Not a very happy name, if you ask me.</p>
<p>[2] Very similar to what you get if you compile the
<code>.ui</code> with <code>pyuic4</code>.</p>
06http://grulicueva.homelinux.net/~mdione/glob//archives/2007/06/2009-11-16T09:37:44Z2009-11-16T09:37:44Z05http://grulicueva.homelinux.net/~mdione/glob//archives/2007/05/2009-11-16T09:37:44Z2009-11-16T09:37:44Z11http://grulicueva.homelinux.net/~mdione/glob//archives/2007/11/2009-11-16T09:37:44Z2009-11-16T09:37:44Z10http://grulicueva.homelinux.net/~mdione/glob//archives/2009/10/2009-11-16T09:37:44Z2009-11-16T09:37:44Z
<div class="inlinepage">
<div class="inlineheader">
<p><span class="header"><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../posts/phonon-and-filenames/">phonon-and-filenames</a></span></p>
</div>
<div class="inlinecontent">
<p>More than two months ago <a href=
"http://grulicueva.homelinux.net/~mdione/glob/posts/from-qstring-to-bytes-in-pyqt/">
I globed about QStrings and paths</a>. The problem was this: my app
accepts paths via command line, which are processed via
<code>KCmdLineOptions</code>; which in turn converts everything to
<code>QString</code>s. What I wanted were paths, which are more
like <code>QByteArray</code>s, not <code>QString</code>s (because
the latter have internally an unicode representation; more on that
later). Including <code>PyQt4</code> in the equation forced me to
resort to <code>QByteArray</code> to get the path as a
<code>str</code> instead of using <code>QString.constData()</code>
(<code>PyQt4</code> doesn't export that function). But that's only
the beginning of the problem.</p>
<p>Take for instance this situation. I have a music collection that
I've been building for years now (more that 10, I think). In the
old times of this collection the filenames were encoded in
<code>iso-8859-1</code>. Then the future came and converted all my
machines to <code>utf-8</code>. But only the software; the
filesystems were in one way or another inherited from system to
system, from machine to machine. So I ended with a mixture of utf
and iso filenames, to the point where I have a file whose filename
is in iso, but the directory where it is is in utf. Yes, I know, it
<em>is</em> a mess. But if I take any decent media player, I can
play the file allright. That's because the filesystem knows nothing
of encodings (otherwise it would reject badly encoded
filenames).</p>
<p>I just spent last saturday making sure that <code>satyr</code>
only stored filepaths in <code>str</code>s, not
<code>unicode</code>s or <code>QString</code>s. It took
concentration, but having just a bunch of classes and only 3 or 4
points where the filepaths are managed it wasn't that difficult.
Still, it took a day. But then, as I mentioned in that post,
<code>Phonon</code> the is not able to play such files... or so I
thought.</p>
<p>If you run <code>satyr</code> after executing <code>export
PHONON_XINE_DEBUG=1</code> you'll see a lot of <code>Phonon</code>
debug info in the console (not that there is another way to run
<code>satyr</code> right now anyways). Among all that info you'll
see lines such as these two:</p>
<pre>
<code>void Phonon::Xine::XineStream::setMrl(const QByteArray&, Phonon::Xine::XineStream::StateForNewMrl) ...
bool Phonon::Xine::XineStream::xineOpen(Phonon::State) xine_open succeeded for m_mrl = ...
</code>
</pre>
<p>If you're sharp enough (I'm not; sandsmark from
<code>#phonon</code> had to tell me) you'll note the mention of
MRL's. MRL's are <code>xine</code>'s URL for media. As any URL,
they can (and most of the time must) encode 'strange' characters
with the so-called "percent encoding". This means that no matter
what encodings the different parts of a filepath is in, I just add
<code>file://</code> at the beginning and then I can safely encode
it scaping non-ascii characters to %xx representations... or that's
what the theory says. One thing to note is that the
<code>file://</code> part <em>must not</em> be scaped;
<code>xine</code> complains that the file does not exist in that
case.</p>
<p>Looking for help in <code>Qt</code>'s classes one can find
<code>QUrl</code> and the already known <code>QByteArray</code>. I
can call <code>QByteArray.toPercentEnconding()</code> from my
<code>str</code> and feed that to
<code>QUrl.fromPercentEncoding()</code> (which strangely returns a
<code>QString</code>, which is exactly what we're avoiding) or
<code>QUrl.fromEncoded()</code>. But then the first function
encodes too much, replacing <code>://</code> with
<code>%3A%2F%2F</code>. No fun.</p>
<p>Ok, let's try creating a <code>QByteArray</code> with only the
<code>file://</code> and then <code>append()</code> the
<code>toPercentEncoding()</code> of the path only. It works:</p>
<pre>
<code>PyQt4.QtCore.QByteArray('file://%2Fhome%2Fmdione...%2F%C3%9Altimo%20bondi%20a%20Finisterre%2F07-%20La%20peque%F1a%20novia%20del%20carioca.wav')
</code>
</pre>
<p>But then calling <code>QUrl.fromEncoded()</code> gives:</p>
<pre>
<code>PyQt4.QtCore.QUrl("file://xn--/home/mdione.../ltimo bondi a finisterre/07- la pequea novia del carioca-wkmz60758d.wav")
</code>
</pre>
<p>The URL got somehow <a href=
"http://en.wikipedia.org/wiki/Punycode">puny-encoded</a>, which of
course <code>xine</code> doesn't recognize for local files.</p>
<p><em>Another</em> option is to create an empty <code>QUrl</code>,
call <code>setEncodedUrl()</code> with the ParsingMode to
<code>QUrl.StrictMode</code> so we avoid 50 lines of code that
start <a href=
"http://qt.gitorious.org/qt/qt/blobs/4.5/src/corelib/io/qurl.cpp#line4094">
here</a>[1] that try to escape everything all over again (and I
already had some double-or-even-triple-enconding nightmares parsing
RSS/Atom feeds last year, thank you), but we get puny-encoded again
(maybe it is 'pwny-encoded'?).</p>
<p>Last resort: backtrack to the point were we created only one
<code>QByteArray</code> with the path and call
<code>toPercentEncoding()</code>; feed that to the method
<code>setEncodedPath()</code> of an empty <code>QUrl</code>. Then
we add the last piece calling <code>setScheme('file')</code> and
we're ready! Of course we're not:</p>
<pre>
<code>PyQt4.QtCore.QByteArray('file:%2Fhome%2Fmdione...%2F%C3%9Altimo%20bondi%20a%20Finisterre%2F07-%20La%20peque%F1a%20novia%20del%20carioca.wav')
</code>
</pre>
<p>Notice the lack of the two <code>//</code> after
<code>file:</code>? <code>xine</code> doesn't like it; hence, I
don't either.</p>
<p>Ok, this post got too long. I hope I can resolve this soon, I
already spent too much time on it. At least a good part of it was
expaining it, so others don't have to suffer the same as I did.</p>
<p>BTW, <code>satyr</code> will shortly be released, whether I fix
this bug or not.</p>
<hr />
<p><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/satyr/">satyr</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/pykde/">pykde</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/phonon/">phonon</a></p>
<hr />
<p>[1] Look at the size of that file! 6k lines to handle URL's! Who
would say it was so difficult... Once more I'm remembered of how
lucky I am to have this libraries at the tips of my fingers,
yay!</p>
</div>
<div class="inlinefooter">
<p><span class="pagedate">Posted <span class="date">Sun 25 Oct 2009
11:57:47 PM CET</span></span></p>
<p><span class="tags">Tags:</span></p>
<p><span class="tags"><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/phonon/" rel=
"tag">phonon</a></span></p>
<p><span class="tags"><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/pykde/" rel=
"tag">pykde</a></span></p>
<p><span class="tags"><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/satyr/" rel=
"tag">satyr</a></span></p>
</div>
</div>
<div class="inlinepage">
<div class="inlineheader">
<p><span class="header"><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../ikiwiki/pagespec/sorting/">sorting</a></span></p>
</div>
<div class="inlinecontent">
<p>Some <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../ikiwiki/directive/">directives</a> that use
<a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../ikiwiki/pagespec/">PageSpecs</a> allow specifying
the order that matching pages are shown in. The following sort
orders can be specified.</p>
<ul>
<li><code>age</code> - List pages from the most recently created to
the oldest.</li>
<li><code>mtime</code> - List pages with the most recently modified
first.</li>
<li><code>title</code> - Order by title.</li>
<li><code>title_natural</code> - Only available if [[!cpan
Sort::Naturally]] is installed. Orders by title, but numbers in the
title are treated as such, ("1 2 9 10 20" instead of "1 10 2 20
9")</li>
</ul>
</div>
<div class="inlinefooter">
<p><span class="pagedate">Posted <span class="date">Wed 21 Oct 2009
07:47:47 PM CEST</span></span></p>
</div>
</div>
<div class="inlinepage">
<div class="inlineheader">
<p><span class="header"><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../posts/satyr/">satyr</a></span></p>
</div>
<div class="inlinecontent">
<p>For a couple of months I've been globbing about PyKDE4 stuff,
and laterally talking about my last project: <code>satyr</code>.
<code>satyr</code> (it's name should always be written in
lowercase) should have the following features:</p>
<ul>
<li>The PlayList and the Collection(s)[0] are the same thing.</li>
<li>Yours is a Collection of Albums, nothing else[3].</li>
<li>Some Albums are from the same artists and some are
compilations[3].</li>
<li>If you want an ephemeral playlist you could queue
songs[1].</li>
<li>If you want non-ephemeral playlists, then this player is not
for you.</li>
<li>Ability to search à la <code>xmms</code>, but in the same
interface[2]</li>
<li>Tag reading and writing[3].</li>
<li>Order you collection based on the tags[3].</li>
<li>The collection discovers new files and adds them to the
playlist on the fly[4].</li>
<li>Be able to use all the program only with your keyboard (die,
mouse, die!)</li>
</ul>
<p>This and other features should be available soon. The coding has
been fast lately, mainly because the Qt/KDE libs are fantastic to
work with. The only thing I couldn't do was to read the tags before
playing them, so I relied into the <code>kaa</code> libraries.</p>
<p><a href="https://savannah.nongnu.org/projects/satyr/">The
project is hosted in savannah</a>, and right now there is no
tarball (It's marked as alpha state because I sent a couple of
tarballs to some friends who asked for them), so the only way right
now is to branch anonimously <a href=
"https://savannah.nongnu.org/bzr/?group=satyr">the
<code>bazaar</code> repo</a>. I hope you download and enjoy it as
much as I do.</p>
<p><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/satyr/">satyr</a> <a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/pykde/">pykde</a></p>
<hr />
<p>[0] The support for several collections is not complete yet.</p>
<p>[1] Functionality available via dbus only at the moment.</p>
<p>[2] This is with the current GUI. I'm also thinking in
several/pluginable GUI's</p>
<p>[3] Not yet available.</p>
<p>[4] Of course this only works if it's running. Otherwise, you
can always ask for a rescanning[1].</p>
</div>
<div class="inlinefooter">
<p><span class="pagedate">Posted <span class="date">Fri 02 Oct 2009
12:21:14 AM CEST</span></span></p>
<p><span class="tags">Tags:</span></p>
<p><span class="tags"><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/pykde/" rel=
"tag">pykde</a></span></p>
<p><span class="tags"><a href="http://grulicueva.homelinux.net/~mdione/glob//archives/2009/../../tags/satyr/" rel=
"tag">satyr</a></span></p>
</div>
</div>
08http://grulicueva.homelinux.net/~mdione/glob//archives/2007/08/2009-11-16T09:37:44Z2009-11-16T09:37:44Z12http://grulicueva.homelinux.net/~mdione/glob//archives/2009/12/2009-11-16T09:37:44Z2009-11-16T09:37:44Z03http://grulicueva.homelinux.net/~mdione/glob//archives/2007/03/2009-11-16T09:37:44Z2009-11-16T09:37:44Z