Author: dmeyer
Date: Wed Feb 13 15:02:34 2008
New Revision: 10366
Log:
strutils updates
Modified:
trunk/core/src/ipc/mbus_wrapper.py
trunk/core/src/ipc/tvserver.py
trunk/tvdev/src/control.py
trunk/tvserver/src/favorite.py
trunk/tvserver/src/recorder.py
trunk/tvserver/src/recording.py
trunk/ui/src/audio/audioitem.py
trunk/ui/src/audio/plugins/album.py
trunk/ui/src/audio/plugins/artist.py
trunk/ui/src/directory.py
trunk/ui/src/fxditem.py
trunk/ui/src/gui/widgets/text.py
trunk/ui/src/image/fxdhandler.py
trunk/ui/src/menu/mediaitem.py
trunk/ui/src/playlist.py
trunk/ui/src/plugins/lcd.py
trunk/ui/src/plugins/mbus.py
trunk/ui/src/tv/favorite.py
trunk/ui/src/tv/program.py
trunk/ui/src/util.py
trunk/ui/src/video/fxdhandler.py
trunk/ui/src/video/videoitem.py
trunk/webserver/src/pages/recordings.py
Modified: trunk/core/src/ipc/mbus_wrapper.py
==============================================================================
--- trunk/core/src/ipc/mbus_wrapper.py (original)
+++ trunk/core/src/ipc/mbus_wrapper.py Wed Feb 13 15:02:34 2008
@@ -56,7 +56,6 @@
# kaa imports
import kaa
-from kaa.strutils import str_to_unicode
# freevo imports
import freevo.conf as conf
@@ -85,7 +84,7 @@
if isinstance(value, dict):
return [ (k, _toMType(v)) for k,v in value.items() ]
if isinstance(value, str):
- return str_to_unicode(value)
+ return kaa.str_to_unicode(value)
return value
Modified: trunk/core/src/ipc/tvserver.py
==============================================================================
--- trunk/core/src/ipc/tvserver.py (original)
+++ trunk/core/src/ipc/tvserver.py Wed Feb 13 15:02:34 2008
@@ -43,7 +43,6 @@
# kaa imports
import kaa
import kaa.epg
-from kaa.strutils import unicode_to_str
# get basic ipc handling
import ipc
@@ -95,7 +94,7 @@
def __str__(self):
- return unicode_to_str(self.__unicode__())
+ return kaa.unicode_to_str(self.__unicode__())
def __getitem__(self, key):
Modified: trunk/tvdev/src/control.py
==============================================================================
--- trunk/tvdev/src/control.py (original)
+++ trunk/tvdev/src/control.py Wed Feb 13 15:02:34 2008
@@ -75,7 +75,6 @@
# kaa imports
import kaa
import kaa.record
-import kaa.strutils
# mbus support
import freevo.ipc
@@ -134,7 +133,7 @@
else:
raise IndexError('%s invalid' % id)
- filename = kaa.strutils.unicode_to_str(filename)
+ filename = kaa.unicode_to_str(filename)
if filename.startswith('file:/'):
filename = filename[5:]
Modified: trunk/tvserver/src/favorite.py
==============================================================================
--- trunk/tvserver/src/favorite.py (original)
+++ trunk/tvserver/src/favorite.py Wed Feb 13 15:02:34 2008
@@ -52,7 +52,7 @@
import logging
# kaa imports
-from kaa.strutils import unicode_to_str, str_to_unicode
+import kaa
# record imports
from config import config
@@ -98,7 +98,7 @@
if child.name == var:
setattr(self, var, child.content)
if child.name == 'url':
- self.url = unicode_to_str(child.content)
+ self.url = kaa.unicode_to_str(child.content)
if child.name == 'once':
self.once = True
if child.name == 'substring':
@@ -141,7 +141,7 @@
"""
Return True if name, channel and start match this favorite.
"""
- if str_to_unicode(name.lower()) != self.name.lower() and not
self.substring:
+ if kaa.str_to_unicode(name.lower()) != self.name.lower() and not
self.substring:
return False
if name.lower().find(self.name.lower()) == -1:
return False
@@ -178,7 +178,7 @@
# url is string and an extra '/' is not allowed. Replace '/'
# with '_' and also convert all args to string.
for o in options:
- options[o] = unicode_to_str(options[o]).replace('/', '_')
+ options[o] = kaa.unicode_to_str(options[o]).replace('/', '_')
for pattern in re.findall('%\([a-z]*\)', text):
if not str(pattern[2:-1]) in options:
options[pattern[2:-1]] = pattern
@@ -198,7 +198,7 @@
if self.url:
# add url template to recording
try:
- rec.url = unicode_to_str(self.__fill_template(rec, self.url,
True) + '.suffix')
+ rec.url = kaa.unicode_to_str(self.__fill_template(rec,
self.url, True) + '.suffix')
except Exception, e:
log.exception('Error setting recording url')
rec.url = ''
@@ -230,7 +230,7 @@
else:
substring = '(exact matching)'
return '%3d %-35s %4d %s %s' % \
- (self.id, unicode_to_str(name), self.priority, once, substring)
+ (self.id, kaa.unicode_to_str(name), self.priority, once,
substring)
def toxml(self, root):
Modified: trunk/tvserver/src/recorder.py
==============================================================================
--- trunk/tvserver/src/recorder.py (original)
+++ trunk/tvserver/src/recorder.py Wed Feb 13 15:02:34 2008
@@ -44,7 +44,6 @@
# kaa imports
import kaa
-from kaa.strutils import unicode_to_str
import kaa.epg
# freevo core imports
@@ -235,7 +234,7 @@
sys.exit(0)
def normalize_name(self, name):
- return unicode_to_str(name.replace('.', '').replace(' ',
'')).upper().strip()
+ return kaa.unicode_to_str(name.replace('.', '').replace(' ',
'')).upper().strip()
def add_channel(self, chan_obj, chan_id):
@@ -346,8 +345,8 @@
Return url (e.g. filename) for the given recording
"""
if not rec.url:
- filename_array = { 'progname': unicode_to_str(rec.name),
- 'title' : unicode_to_str(rec.subtitle) }
+ filename_array = { 'progname': kaa.unicode_to_str(rec.name),
+ 'title' : kaa.unicode_to_str(rec.subtitle) }
filemask = config.record.filemask % filename_array
filename = ''
Modified: trunk/tvserver/src/recording.py
==============================================================================
--- trunk/tvserver/src/recording.py (original)
+++ trunk/tvserver/src/recording.py Wed Feb 13 15:02:34 2008
@@ -40,7 +40,7 @@
import os
# kaa imports
-from kaa.strutils import unicode_to_str, str_to_unicode
+import kaa
# freevo imports
import freevo.fxdparser
@@ -102,13 +102,13 @@
self.stop_padding = config.record.stop_padding
for key, value in info.items():
if key in ('subtitle', 'description') and value:
- setattr(self, key, str_to_unicode(value))
+ setattr(self, key, kaa.str_to_unicode(value))
elif key == 'url' and value:
- self.url = unicode_to_str(value)
+ self.url = kaa.unicode_to_str(value)
elif key in ('start-padding', 'stop_padding'):
setattr(self, key, int(value))
elif value:
- self.info[key] = str_to_unicode(value)
+ self.info[key] = kaa.str_to_unicode(value)
self.recorder = None
self.respect_start_padding = True
@@ -124,7 +124,7 @@
if child.name == var:
setattr(self, var, child.content)
if child.name == 'url':
- self.url = unicode_to_str(child.content)
+ self.url = kaa.unicode_to_str(child.content)
if child.name == 'priority':
self.priority = int(child.content)
if child.name == 'padding':
@@ -156,9 +156,9 @@
if self.episode:
info['episode'] = self.episode
if self.url:
- info['url'] = str_to_unicode(self.url)
+ info['url'] = kaa.str_to_unicode(self.url)
if self.description:
- info['description'] = str_to_unicode(self.description)
+ info['description'] = kaa.str_to_unicode(self.description)
return self.id, self.name, self.channel, self.priority, self.start, \
self.stop, self.status, self.start_padding, self.stop_padding, \
info
@@ -192,10 +192,10 @@
stop_padding = 0
return '%3d %10s %-25s %4d %s-%s %2s %2s %s' % \
- (self.id, unicode_to_str(channel), unicode_to_str(name),
+ (self.id, kaa.unicode_to_str(channel), kaa.unicode_to_str(name),
self.priority, _int2time(self.start)[4:],
_int2time(self.stop)[9:], start_padding,
- stop_padding, unicode_to_str(status))
+ stop_padding, kaa.unicode_to_str(status))
def toxml(self, root):
@@ -208,7 +208,7 @@
if getattr(self, var):
node.add_child(var, getattr(self, var))
if self.url:
- node.add_child('url', str_to_unicode(self.url))
+ node.add_child('url', kaa.str_to_unicode(self.url))
node.add_child('timer', start=_int2time(self.start),
stop=_int2time(self.stop))
node.add_child('padding', start=self.start_padding,
stop=self.stop_padding)
Modified: trunk/ui/src/audio/audioitem.py
==============================================================================
--- trunk/ui/src/audio/audioitem.py (original)
+++ trunk/ui/src/audio/audioitem.py Wed Feb 13 15:02:34 2008
@@ -39,9 +39,6 @@
import logging
import time
-# kaa imports
-from kaa.strutils import str_to_unicode
-
# freevo imports
from freevo.ui.menu import MediaItem, Action
from freevo.ui.event import PLAY_END, STOP
Modified: trunk/ui/src/audio/plugins/album.py
==============================================================================
--- trunk/ui/src/audio/plugins/album.py (original)
+++ trunk/ui/src/audio/plugins/album.py Wed Feb 13 15:02:34 2008
@@ -36,8 +36,8 @@
# -----------------------------------------------------------------------------
# Kaa imports
+import kaa
import kaa.beacon
-from kaa.strutils import str_to_unicode
# Freevo imports
from freevo.ui.mainmenu import MainMenuPlugin
@@ -63,10 +63,10 @@
"""
Show all items from that artist.
"""
- title = str_to_unicode(self.artist)
+ title = kaa.str_to_unicode(self.artist)
if self.album:
query = kaa.beacon.query(artist=self.artist, album=self.album,
type='audio')
- title = '%s - %s' % (title, str_to_unicode(self.album))
+ title = '%s - %s' % (title, kaa.str_to_unicode(self.album))
else:
query = kaa.beacon.query(artist=self.artist, type='audio')
# FIXME: monitor query for live update
@@ -131,7 +131,7 @@
artist = self.artists[self.base_row+row]
# Work around a beacon bug
for part in artist.split(' '):
- artist_name += ' ' + str_to_unicode(part.capitalize())
+ artist_name += ' ' + kaa.str_to_unicode(part.capitalize())
artist_name = artist_name.strip()
return artist_name
Modified: trunk/ui/src/audio/plugins/artist.py
==============================================================================
--- trunk/ui/src/audio/plugins/artist.py (original)
+++ trunk/ui/src/audio/plugins/artist.py Wed Feb 13 15:02:34 2008
@@ -36,8 +36,8 @@
# -----------------------------------------------------------------------------
# Kaa imports
+import kaa
import kaa.beacon
-from kaa.strutils import str_to_unicode
# Freevo imports
from freevo.ui.mainmenu import MainMenuPlugin
@@ -61,10 +61,10 @@
"""
Show all items from that artist.
"""
- title = str_to_unicode(self.artist)
+ title = kaa.str_to_unicode(self.artist)
if self.album:
query = kaa.beacon.query(artist=self.artist, album=self.album,
type='audio')
- title = '%s - %s' % (title, str_to_unicode(self.album))
+ title = '%s - %s' % (title, kaa.str_to_unicode(self.album))
else:
query = kaa.beacon.query(artist=self.artist, type='audio')
# FIXME: monitor query for live update
@@ -90,7 +90,7 @@
# Work around a beacon bug
for part in artist.split(' '):
- self.name += ' ' + str_to_unicode(part.capitalize())
+ self.name += ' ' + kaa.str_to_unicode(part.capitalize())
self.name = self.name.strip()
Modified: trunk/ui/src/directory.py
==============================================================================
--- trunk/ui/src/directory.py (original)
+++ trunk/ui/src/directory.py Wed Feb 13 15:02:34 2008
@@ -40,7 +40,6 @@
import kaa
import kaa.beacon
from kaa.weakref import weakref
-from kaa.strutils import str_to_unicode
# freevo imports
from freevo.ui import config
@@ -117,7 +116,7 @@
self.files.read_only = True
self.files.append(directory)
if name:
- self.name = str_to_unicode(name)
+ self.name = kaa.str_to_unicode(name)
if self['show_all_items']:
# FIXME: no way to set this
self.media_type = None
Modified: trunk/ui/src/fxditem.py
==============================================================================
--- trunk/ui/src/fxditem.py (original)
+++ trunk/ui/src/fxditem.py Wed Feb 13 15:02:34 2008
@@ -36,7 +36,7 @@
import os
# kaa imports
-from kaa.strutils import unicode_to_str
+import kaa
# freevo core imports
import freevo.fxdparser
@@ -145,7 +145,7 @@
c.info = {}
for attr in c.children:
if attr.name == 'cover-img' and attr.content:
- image = os.path.join(dirname, unicode_to_str(attr.content))
+ image = os.path.join(dirname,
kaa.unicode_to_str(attr.content))
if os.path.isfile(image):
c.image = image
if attr.name == 'info':
Modified: trunk/ui/src/gui/widgets/text.py
==============================================================================
--- trunk/ui/src/gui/widgets/text.py (original)
+++ trunk/ui/src/gui/widgets/text.py Wed Feb 13 15:02:34 2008
@@ -36,7 +36,7 @@
import os
import logging
-from kaa.strutils import to_str
+import kaa
# mevas imports
import kaa.mevas
@@ -250,5 +250,7 @@
t = self.text[:20]
else:
t = self.text
- return 'Text: "%s", zindex=%s' % (to_str(t), self.get_zindex())
+ if not isinstance(t, (str, unicode)):
+ t = str(t)
+ return 'Text: "%s", zindex=%s' % (kaa.unicode_to_str(t),
self.get_zindex())
Modified: trunk/ui/src/image/fxdhandler.py
==============================================================================
--- trunk/ui/src/image/fxdhandler.py (original)
+++ trunk/ui/src/image/fxdhandler.py Wed Feb 13 15:02:34 2008
@@ -55,7 +55,7 @@
import os
# kaa imports
-from kaa.strutils import unicode_to_str
+import kaa
# Freevo imports
from freevo.ui import config
@@ -84,7 +84,7 @@
# Create a list of all images for the slideshow
for child in children:
try:
- fname = os.path.join(dirname, unicode_to_str(fxd.gettext(child)))
+ fname = os.path.join(dirname,
kaa.unicode_to_str(fxd.gettext(child)))
files = []
if child.name == 'directory':
# for directories add all files in it
Modified: trunk/ui/src/menu/mediaitem.py
==============================================================================
--- trunk/ui/src/menu/mediaitem.py (original)
+++ trunk/ui/src/menu/mediaitem.py Wed Feb 13 15:02:34 2008
@@ -37,8 +37,8 @@
import time
# kaa imports
+import kaa
import kaa.beacon
-from kaa.strutils import str_to_unicode
# freevo imports
from freevo.ui.event import PLAY_START, STOP
@@ -93,7 +93,7 @@
self.parent['config:use_metadata'] in (None, True):
self.name = self.info.get('title')
if not self.name:
- self.name = str_to_unicode(self.info.get('name'))
+ self.name = kaa.str_to_unicode(self.info.get('name'))
else:
# Mode is not file, it has to be a network url. Other
@@ -102,7 +102,7 @@
if not self.name:
self.name = self.info.get('title')
if not self.name:
- self.name = str_to_unicode(self.url)
+ self.name = kaa.str_to_unicode(self.url)
def _format_time(self, time, hours=False):
Modified: trunk/ui/src/playlist.py
==============================================================================
--- trunk/ui/src/playlist.py (original)
+++ trunk/ui/src/playlist.py Wed Feb 13 15:02:34 2008
@@ -37,8 +37,8 @@
import logging
# kaa imports
+import kaa
import kaa.beacon
-from kaa.strutils import str_to_unicode, unicode_to_str
from kaa.weakref import weakref
# freevo imports
@@ -79,7 +79,7 @@
"""
MediaItem.__init__(self, parent)
ItemList.__init__(self)
- self.name = str_to_unicode(name)
+ self.name = kaa.str_to_unicode(name)
if self.type == 'tv':
type = 'video'
@@ -491,7 +491,7 @@
continue
for file in c.children:
if file.name in ('file', 'directory'):
- f = unicode_to_str(file.content)
+ f = kaa.unicode_to_str(file.content)
filename = os.path.join(node.dirname, f)
query = kaa.beacon.query(filename=filename)
if file.name == 'directory':
Modified: trunk/ui/src/plugins/lcd.py
==============================================================================
--- trunk/ui/src/plugins/lcd.py (original)
+++ trunk/ui/src/plugins/lcd.py Wed Feb 13 15:02:34 2008
@@ -28,7 +28,6 @@
import re
import kaa
-from kaa.strutils import unicode_to_str
from freevo import plugin
from freevo.ui import application
@@ -141,7 +140,7 @@
if r == None:
return ''
if isinstance(r, unicode):
- return unicode_to_str(r)
+ return kaa.unicode_to_str(r)
return str(r)
except (SystemExit, KeyboardInterrupt):
raise SystemExit
@@ -163,7 +162,7 @@
args = []
for a in w[1]:
if isinstance(a, unicode):
- a = unicode_to_str(a)
+ a = kaa.unicode_to_str(a)
if isinstance(a, str) and a.find('%%') >= 0:
a = varreg.subn(cb, a)[0]
args.append(a)
Modified: trunk/ui/src/plugins/mbus.py
==============================================================================
--- trunk/ui/src/plugins/mbus.py (original)
+++ trunk/ui/src/plugins/mbus.py Wed Feb 13 15:02:34 2008
@@ -1,6 +1,5 @@
# kaa imports
import kaa
-from kaa.strutils import unicode_to_str
import kaa.beacon
# freevo core imports
@@ -60,7 +59,7 @@
if not app or app.get_name() != 'menu':
raise RuntimeError('freevo not in menu mode')
- kaa.beacon.query(filename=unicode_to_str(file)).get(filter='extmap')
+
kaa.beacon.query(filename=kaa.unicode_to_str(file)).get(filter='extmap')
# normal file
for p in MediaPlugin.plugins(type):
Modified: trunk/ui/src/tv/favorite.py
==============================================================================
--- trunk/ui/src/tv/favorite.py (original)
+++ trunk/ui/src/tv/favorite.py Wed Feb 13 15:02:34 2008
@@ -37,7 +37,6 @@
# kaa imports
import kaa.epg
-from kaa.strutils import unicode_to_str
# freevo ui imports
from freevo.ui import config
@@ -171,7 +170,7 @@
@kaa.coroutine()
def add(self):
result = yield tvserver.favorites.add(self.title, self.channels,
self.days,
- [self._time_to_str()], 50, False)
+ [self._format_time()], 50, False)
if result != tvserver.favorites.SUCCESS:
text = _('Adding favorite Failed')+(': %s' % result)
else:
@@ -279,7 +278,7 @@
self.stop = float(1440*60)-1
else:
self.start = value
- infovalue = [self._time_to_str()]
+ infovalue = [self._format_time()]
if item == 'stop':
info = 'times'
if value == 'ANY':
@@ -287,14 +286,14 @@
self.stop = float(1440*60)-1
else:
self.stop = value
- infovalue = [self._time_to_str()]
+ infovalue = [self._format_time()]
if not self.new:
self.modify([(info, infovalue)])
self.get_menustack().back_one_menu()
- def _time_to_str(self):
+ def _format_time(self):
start = time.strftime('%H:%M', time.gmtime(self.start))
stop = time.strftime('%H:%M', time.gmtime(self.stop))
return start + '-' + stop
Modified: trunk/ui/src/tv/program.py
==============================================================================
--- trunk/ui/src/tv/program.py (original)
+++ trunk/ui/src/tv/program.py Wed Feb 13 15:02:34 2008
@@ -38,7 +38,6 @@
# kaa imports
import kaa
import kaa.epg
-from kaa.strutils import unicode_to_str
# freevo core imports
import freevo.ipc
@@ -132,7 +131,7 @@
"""
return as string for debug
"""
- return unicode_to_str(self.__unicode__())
+ return kaa.unicode_to_str(self.__unicode__())
def __cmp__(self, other):
Modified: trunk/ui/src/util.py
==============================================================================
--- trunk/ui/src/util.py (original)
+++ trunk/ui/src/util.py Wed Feb 13 15:02:34 2008
@@ -39,7 +39,6 @@
# kaa imports
import kaa
-from kaa.strutils import str_to_unicode
# get logging object
log = logging.getLogger()
@@ -134,7 +133,7 @@
def __getitem__(self, key):
if isinstance(key, str):
- key = str_to_unicode(key)
+ key = kaa.str_to_unicode(key)
try:
del self.lru[self.lru.index(key)]
@@ -146,7 +145,7 @@
def __setitem__(self, key, object):
if isinstance(key, str):
- key = str_to_unicode(key)
+ key = kaa.str_to_unicode(key)
try:
# remove old one if key is already in cache
@@ -167,7 +166,7 @@
def __delitem__(self, key):
if isinstance(key, str):
- key = str_to_unicode(key)
+ key = kaa.str_to_unicode(key)
if not key in self.cache:
return
Modified: trunk/ui/src/video/fxdhandler.py
==============================================================================
--- trunk/ui/src/video/fxdhandler.py (original)
+++ trunk/ui/src/video/fxdhandler.py Wed Feb 13 15:02:34 2008
@@ -65,7 +65,7 @@
import logging
# kaa imports
-from kaa.strutils import unicode_to_str
+import kaa
import kaa.beacon
# freevo imports
@@ -85,7 +85,7 @@
if c.name == 'video':
for f in c.children:
if f.name == 'file':
- filename = unicode_to_str(f.content)
+ filename = kaa.unicode_to_str(f.content)
# FIXME: make this faster
for f in listing.get('beacon:all'):
Modified: trunk/ui/src/video/videoitem.py
==============================================================================
--- trunk/ui/src/video/videoitem.py (original)
+++ trunk/ui/src/video/videoitem.py Wed Feb 13 15:02:34 2008
@@ -43,7 +43,7 @@
import time
# kaa imports
-from kaa.strutils import unicode_to_str, str_to_unicode
+import kaa
# freevo imports
from freevo.ui import config
@@ -111,7 +111,7 @@
if show_name:
# This matches a tv show with a show name, an epsiode and
# a title of the specific episode
- sn = unicode_to_str(show_name[0].lower())
+ sn = kaa.unicode_to_str(show_name[0].lower())
if database.tv_shows.has_key(sn):
tvinfo = database.tv_shows[sn]
self.info.set_variables(tvinfo[1])
Modified: trunk/webserver/src/pages/recordings.py
==============================================================================
--- trunk/webserver/src/pages/recordings.py (original)
+++ trunk/webserver/src/pages/recordings.py Wed Feb 13 15:02:34 2008
@@ -35,7 +35,7 @@
import logging
# kaa imports
-from kaa.strutils import str_to_unicode
+import kaa
import kaa.epg
# freevo core imports
@@ -80,7 +80,7 @@
prog = None
for p in progs:
- if str_to_unicode(chan) == kaa.epg.get_channel(p.channel).name
\
+ if kaa.str_to_unicode(chan) ==
kaa.epg.get_channel(p.channel).name \
and int(start) == p.start:
prog = p
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog