<br><br><div class="gmail_quote">On Tue, Oct 18, 2011 at 10:54 AM,  <span dir="ltr"><<a href="mailto:daitheflu@free.fr" target="_blank">daitheflu@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



Hi,<br>
<br>
Thanks Sebastian, that helped me *a lot*.<br>
<br>
I checked with NepomukShell and discovered that my artwork Resource had no NIE:url !<br>
I thought that the constructor would have automatically set it but it didn't, and it does not.<br>
<br>
Since the following wasn't sufficient :<br>
<br>
    img = Nepomuk.Resource(coverpath, OntologiesUrls.image())<br>
<br>
I just added :<br>
<br>
    img = Nepomuk.Resource(coverpath, OntologiesUrls.image())<br>
    img.setProperty(OntologiesUrls.url(), coverpath)<br>
<br>
And that did the trick :)<br>
It's now working like a charm !<br>
<br>
<br>
<br>
As for your Python tool that generate ontologies, that could be very interesting.<br>
I could have write one by myself, but I was too lazy. So I just hardcoded the one I needed.<br>
If yours is not too difficult to understand and if you're OK, I could maybe maintain it.<br></blockquote><div><br></div><div>I write one my own but is not a class is a function an its usage is:</div><div><br></div><div>

<b><font class="Apple-style-span" face="'courier new', monospace">

NOC('nie:url')</font></b></div><div><b><font class="Apple-style-span" face="'courier new', monospace"><br></font></b></div><div><font class="Apple-style-span" face="'courier new', monospace">or</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"><b><br></b></font></div><div><b><font class="Apple-style-span" face="'courier new', monospace">NOC('nie:url', True)</font></b></div>

<div><b><font class="Apple-style-span" face="'courier new', monospace"><br></font></b></div><div><font class="Apple-style-span" face="'courier new', monospace">if you want the result was a QUrl.</font></div>

<div><br></div><div>You need to know the ontology but few is hardcoded so function is almost automantained.</div><div><br></div><div><---------------------------></div>
<div><div><font face="'courier new', monospace"><b>knownOntologies = [ \</b></font></div><div><font face="'courier new', monospace"><b>                    ['nao', '2007/08/15'], ['ncal', '2007/04/02'], \</b></font></div>


<div><font face="'courier new', monospace"><b>                    ['nco', '2007/03/22'], ['nexif', '2007/05/10'], \</b></font></div><div><font face="'courier new', monospace"><b>                    ['nfo', '2007/03/22'], ['nid3', '2007/05/10'], \</b></font></div>


<div><font face="'courier new', monospace"><b>                    ['nie', '2007/01/19'], ['nmm', '2009/02/19'], \</b></font></div><div><font face="'courier new', monospace"><b>                    ['nmo', '2007/03/22'], ['nrl', '2007/08/15'], \</b></font></div>


<div><font face="'courier new', monospace"><b>                    ['pimo', '2007/11/01'], ['tmo',  '2008/05/20'] \</b></font></div><div><font face="'courier new', monospace"><b>                ]</b></font></div>


</div><div><font face="'courier new', monospace"><b><br></b></font></div><div><font face="'courier new', monospace"><b># Nepomuk Ontology Converter.</b></font></div><div><div>
<font face="'courier new', monospace"><b>def NOC(name = '', returnQUrl = False):</b></font></div><div><font face="'courier new', monospace"><b>    ontology, property = name.strip().split(':')</b></font></div>


<div><font face="'courier new', monospace"><b>    date = lvalue(knownOntologies, ontology, 0, 1)</b></font></div><div><font face="'courier new', monospace"><b>    if date != None:</b></font></div>
<div><font face="'courier new', monospace"><b>        value = '<a href="http://www.semanticdesktop.org/ontologies/" target="_blank">http://www.semanticdesktop.org/ontologies/</a>%s/%s#%s' % (date, ontology, property)</b></font></div>


<div><font face="'courier new', monospace"><b><br></b></font></div><div><font face="'courier new', monospace"><b>    else:</b></font></div><div><font face="'courier new', monospace"><b>        value = 'Soprano.Vocabulary.%s.%s().toString()' % (ontology.upper(), property)</b></font></div>


<div><font face="'courier new', monospace"><b>        try:</b></font></div><div><font face="'courier new', monospace"><b>            value = eval(value)</b></font></div>
<div><font face="'courier new', monospace"><b><br></b></font></div><div><font face="'courier new', monospace"><b>        except:</b></font></div><div><font face="'courier new', monospace"><b>            value = ''</b></font></div>


<div><font face="'courier new', monospace"><b><br></b></font></div><div><font face="'courier new', monospace"><b>    if returnQUrl:</b></font></div><div><font face="'courier new', monospace"><b>        return QUrl(value)</b></font></div>


<div><font face="'courier new', monospace"><b><br></b></font></div><div><font face="'courier new', monospace"><b>    else:</b></font></div><div><font face="'courier new', monospace"><b>        return value</b></font></div>


</div><div><---------------------------></div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Thanks again for your help.<br>
<br>
Cheers,<br>
<font color="#888888"><br>
--<br>
François<br>
<br>
<br>
<br>
----- Mail original -----<br>
De: "Sebastian Trüg" <<a href="mailto:trueg@kde.org" target="_blank">trueg@kde.org</a>><br>
À: <a href="mailto:nepomuk@kde.org" target="_blank">nepomuk@kde.org</a><br>
Envoyé: Lundi 17 Octobre 2011 20:24:54<br>
Objet: Re: [Nepomuk] Retrieve "linked" artwork file<br>
</font><div><div></div><div><br>
On 10/17/2011 04:20 PM, <a href="mailto:daitheflu@free.fr" target="_blank">daitheflu@free.fr</a> wrote:<br>
> Hi guys,<br>
><br>
> Me again. I'd like my application to link some file as an artwork for a Movie Type Resource.<br>
> The artwork consists in a .png file, stored in some directory (that's not the important point).<br>
><br>
> Here is how I "link" the file to the artwork "property" of the Movie Resource (Python code, but you'll understand) :<br>
><br>
> ***<br>
><br>
> # self.artwork is a QPixmap containg the artwork.<br>
><br>
> if not self.artwork.isNull():<br>
>     # SNIP : saves the cover to `coverpath`.<br>
>     # `coverpath` is a KUrl instance.<br>
><br>
>     # Build a Resource of type NFO:image from the saved picture :<br>
>     img = Nepomuk.Resource(coverpath, OntologiesUrls.image())<br>
<br>
This reminds me that I have a python tool somewhere which generates<br>
ontology methods for python... have to look for it...<br>
<br>
>     # "Links" that NFO:image Resource to the NMM:artwork property of my Movie Resource :<br>
>     resource.setProperty(OntologiesUrls.artwork(), Nepomuk.Variant(img))<br>
><br>
> ***<br>
><br>
><br>
> The problem is to get the .png file back. Here is what I tried :<br>
><br>
><br>
> ***<br>
><br>
> # Get the Resource linked by the NMM:artwork property :<br>
> artwork = resource.property(OntologiesUrls.artwork())<br>
><br>
> if artwork.isValid():<br>
>     imgResource = artwork.toResource()<br>
>     res.artwork = PictureLoader.load_pixmap(imgResource.toFile().url())<br>
><br>
> ***<br>
><br>
> The problem is that `imgResource.toFile().url()` returns an empty KUrl.<br>
><br>
> Am I missing something ? What did I misunderstood ? How can I retrieve and load the linked artwork file ?<br>
<br>
it looks correct. Maybe use nepomukshell to look at the resources to<br>
make sure. You can use a query like "select * where { ?r nmm:artwork ?v<br>
. }" and then double-click on the resource.<br>
<br>
Cheers,<br>
Sebastian<br>
_______________________________________________<br>
Nepomuk mailing list<br>
<a href="mailto:Nepomuk@kde.org" target="_blank">Nepomuk@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/nepomuk" target="_blank">https://mail.kde.org/mailman/listinfo/nepomuk</a><br>
_______________________________________________<br>
Nepomuk mailing list<br>
<a href="mailto:Nepomuk@kde.org" target="_blank">Nepomuk@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/nepomuk" target="_blank">https://mail.kde.org/mailman/listinfo/nepomuk</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Best wishes,<div>Ignacio</div><div><br></div><br>