Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
PyDCOP and Unicode
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Kenji Miyamoto
Veteran
Veteran


Joined: 28 May 2005
Posts: 1452
Location: Looking over your shoulder.

PostPosted: Fri Mar 07, 2008 4:35 pm    Post subject: PyDCOP and Unicode Reply with quote

I'm working on a music-related DCOP application for interfacing with Amarok in Python, but the lack of Unicode support prevents me from doing too much with my collection. For example, I can pass an artist who has a romanized name to amarok.collection.query() and it'll return the songs using Python's Unicode encoding method ('\xNN'), but if I pass an artist with a Japanese name to the same function, it returns nothing.

Here's the code for the function:
Code:
   def fquery(self, amarok = False, title = None, artist = None, album = None):
      if(not amarok):
         amarok = self.amarok
      base = "SELECT tags.url FROM tags INNER JOIN artist ON artist.id = tags.artist LEFT OUTER JOIN album ON album.id = tags.album LEFT OUTER JOIN year ON year.id = tags.year"
      supp = self.QList()
      if title:
         supp += ["tags.title = '%s'" % (escape(title),)]
      if artist:
         supp += ["artist.name = '%s'" % (escape(artist),)]
      if album:
         supp += ["album.name = '%s'" % (escape(album),)]
      if len(supp):
         base += ' WHERE ' + str(supp)
      print base
      ret = amarok.collection.query(base)
      print ret
      return ret
Passing '中島みゆき' to the function gives this output:
Code:
artist.name = '中島みゆき' artist.name = '中島みゆき'
SELECT tags.url FROM tags INNER JOIN artist ON artist.id = tags.artist LEFT OUTER JOIN album ON album.id = tags.album LEFT OUTER JOIN year ON year.id = tags.year WHERE artist.name = '中島みゆき'
[]
Is there anything I can do with this?

I've managed to get some other things working with Unicode by piping the data to the 'dcop' command-line client, but the output from piping out of it won't be structured, and would require a lot of extra work to parse. For all I know, Python's pipe setup may somehow corrupt the Unicode being output by the DCOP client.
_________________
[ Kawa-kun, new and improved!! ]

Alex Libman seems to be more of an anarchist than a libertarian.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum