Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26045/src
Modified Files:
item.py
Log Message:
remove some code which is in other files now
Index: item.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/item.py,v
retrieving revision 1.88
retrieving revision 1.89
diff -C2 -d -r1.88 -r1.89
*** item.py 7 Jan 2005 20:44:57 -0000 1.88
--- item.py 8 Jan 2005 11:45:46 -0000 1.89
***************
*** 1,66 ****
# -*- coding: iso-8859-1 -*-
! # -----------------------------------------------------------------------
# item.py - Template for an item
! # -----------------------------------------------------------------------
# $Id$
#
! # Notes:
! # Todo:
! #
! # -----------------------------------------------------------------------
! # $Log$
! # Revision 1.88 2005/01/07 20:44:57 dischi
! # handle None returns as nothing for getattr
! #
! # Revision 1.87 2004/12/30 11:31:51 dischi
! # rename id to __id__
! #
! # Revision 1.86 2004/12/28 18:09:58 dischi
! # add extra Action class for item actions
! #
! # Revision 1.85 2004/11/20 18:22:59 dischi
! # use python logger module for debug
! #
! # Revision 1.84 2004/11/13 15:56:12 dischi
! # do not import mediainfo in util.__init__
! #
! # Revision 1.83 2004/11/01 20:14:14 dischi
! # fix debug
! #
! # Revision 1.82 2004/10/26 19:14:50 dischi
! # adjust to new sysconfig file
! #
! # Revision 1.81 2004/09/13 19:39:25 dischi
! # every meddiaitem has play/stop functions
! #
! # Revision 1.80 2004/08/27 14:25:03 dischi
! # create extra item type for media items
! #
! # Revision 1.79 2004/08/26 15:26:49 dischi
! # add code to do some memory debugging
! #
! # Revision 1.78 2004/08/24 19:23:36 dischi
! # more theme updates and design cleanups
! #
! # Revision 1.77 2004/08/24 16:42:39 dischi
! # Made the fxdsettings in gui the theme engine and made a better
! # integration for it. There is also an event now to let the plugins
! # know that the theme is changed.
! #
! # Revision 1.76 2004/08/05 17:38:25 dischi
! # remove skin dep
! #
! # Revision 1.75 2004/08/01 10:56:00 dischi
! # do not hide/show the menu, it can do that itself
! #
! # Revision 1.74 2004/07/10 12:33:36 dischi
! # header cleanup
#
! # Revision 1.73 2004/05/29 12:33:16 dischi
! # make it possible to access parent data
#
! # -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
! # Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
--- 1,18 ----
# -*- coding: iso-8859-1 -*-
! #
-----------------------------------------------------------------------------
# item.py - Template for an item
! #
-----------------------------------------------------------------------------
# $Id$
#
! # This file contains a basic item for the menu and a special one for items
! # based on media content. There is also a base class for actions to be
! # returned by the actions() function.
#
! # First edition: Dirk Meyer <[EMAIL PROTECTED]>
! # Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
#
! #
-----------------------------------------------------------------------------
# Freevo - A Home Theater PC framework
! # Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
***************
*** 79,94 ****
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
! # ----------------------------------------------------------------------- */
import os
import gettext
import shutil
! import config
! from event import *
import plugin
import util
- import gui
from sysconfig import Unicode
--- 31,48 ----
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
! #
-----------------------------------------------------------------------------
!
! __all__ = [ 'FileInformation', 'Action', 'Item', 'MediaItem' ]
+ # python imports
import os
import gettext
import shutil
+ import logging
! # freevo imports
import plugin
import util
from sysconfig import Unicode
***************
*** 96,105 ****
import util.mediainfo as mediainfo
! import logging
log = logging.getLogger()
class FileInformation:
"""
! file operations for an item
"""
def __init__(self):
--- 50,60 ----
import util.mediainfo as mediainfo
! # get logging object
log = logging.getLogger()
+
class FileInformation:
"""
! File operations for an item.
"""
def __init__(self):
***************
*** 111,126 ****
def append(self, filename):
self.files.append(filename)
def get(self):
return self.files
def copy_possible(self):
return self.files != []
!
def copy(self, destdir):
for f in self.files + [ self.fxd_file, self.image ]:
if f:
--- 66,93 ----
def append(self, filename):
+ """
+ Append a file to the list.
+ """
self.files.append(filename)
def get(self):
+ """
+ Return all files.
+ """
return self.files
def copy_possible(self):
+ """
+ Return true if it is possible to copy the files.
+ """
return self.files != []
!
def copy(self, destdir):
+ """
+ Copy all files to destdir.
+ """
for f in self.files + [ self.fxd_file, self.image ]:
if f:
***************
*** 135,142 ****
--- 102,115 ----
def move_possible(self):
+ """
+ Return true if it is possible to move the files.
+ """
return self.files and not self.read_only
def move(self, destdir):
+ """
+ Move all files to destdir.
+ """
for f in self.files + [ self.fxd_file, self.image ]:
if f:
***************
*** 151,158 ****
--- 124,137 ----
def delete_possible(self):
+ """
+ Return true if it is possible to delete the files.
+ """
return self.files and not self.read_only
def delete(self):
+ """
+ Delete all files.
+ """
for f in self.files + [ self.fxd_file, self.image ]:
if not f:
***************
*** 165,169 ****
except:
log.error('can\'t delete %s' % f)
!
class Action:
--- 144,148 ----
except:
log.error('can\'t delete %s' % f)
!
class Action:
***************
*** 186,190 ****
if self.function:
self.function(arg=self.arg, menuw=menuw)
!
class Item:
--- 165,169 ----
if self.function:
self.function(arg=self.arg, menuw=menuw)
!
class Item:
***************
*** 194,198 ****
VideoItem, AudioItem and ImageItem
"""
! def __init__(self, parent=None, info=None, skin_type=None):
"""
Init the item. Sets all needed variables, if parent is given also
--- 173,177 ----
VideoItem, AudioItem and ImageItem
"""
! def __init__(self, parent=None, info=None):
"""
Init the item. Sets all needed variables, if parent is given also
***************
*** 217,227 ****
self.autovars = []
- if info and parent and \
- hasattr(parent, 'DIRECTORY_USE_MEDIAID_TAG_NAMES') and \
- parent.DIRECTORY_USE_MEDIAID_TAG_NAMES and \
- self.info.has_key('title'):
- self.name = self.info['title']
-
if parent:
self.image = parent.image
if hasattr(parent, 'is_mainmenu_item'):
--- 196,205 ----
self.autovars = []
if parent:
+ if info and hasattr(parent, 'DIRECTORY_USE_MEDIAID_TAG_NAMES') \
+ and parent.DIRECTORY_USE_MEDIAID_TAG_NAMES and \
+ self.info.has_key('title'):
+ self.name = self.info['title']
+
self.image = parent.image
if hasattr(parent, 'is_mainmenu_item'):
***************
*** 229,234 ****
self.skin_fxd = parent.skin_fxd
self.media = parent.media
- if hasattr(parent, '_'):
- self._ = parent._
else:
self.image = None # imagefile
--- 207,210 ----
***************
*** 236,258 ****
self.media = None
-
self.fxd_file = None
! if skin_type:
! theme = gui.get_theme()
! skin_info = theme.mainmenu.items
! imagedir = theme.mainmenu.imagedir
! if skin_info.has_key(skin_type):
! skin_info = skin_info[skin_type]
! self.name = _(skin_info.name)
! self.image = skin_info.image
! if skin_info.icon:
! self.icon = os.path.join(theme.icon_dir, skin_info.icon)
! if skin_info.outicon:
! self.outicon = os.path.join(theme.icon_dir,
! skin_info.outicon)
! if not self.image and imagedir:
! self.image = util.getimage(os.path.join(imagedir, skin_type))
!
def __setitem__(self, key, value):
--- 212,218 ----
self.media = None
self.fxd_file = None
!
def __setitem__(self, key, value):
***************
*** 271,275 ****
self.info[key] = value
!
def store_info(self, key, value):
"""
--- 231,235 ----
self.info[key] = value
!
def store_info(self, key, value):
"""
***************
*** 292,296 ****
log.warning('unable to delete info for that kind of item')
!
def __id__(self):
"""
--- 252,256 ----
log.warning('unable to delete info for that kind of item')
!
def __id__(self):
"""
***************
*** 302,306 ****
return self.name
!
def sort(self, mode=None):
"""
--- 262,266 ----
return self.name
!
def sort(self, mode=None):
"""
***************
*** 309,327 ****
return u'0%s' % self.name
-
- def translation(self, application):
- """
- Loads the gettext translation for this item (and all it's children).
- This can be used in plugins who are not inside the Freevo
distribution.
- After loading the translation, gettext can be used by self._() instead
- of the global _().
- """
- try:
- self._ = gettext.translation(application,
- os.environ['FREEVO_LOCALE'],
- fallback=1).gettext
- except:
- self._ = lambda m: m
-
def actions(self):
--- 269,272 ----
***************
*** 339,343 ****
if self.actions():
return self.actions()[0][0](arg=arg, menuw=menuw)
!
def eventhandler(self, event, menuw=None):
--- 284,288 ----
if self.actions():
return self.actions()[0][0](arg=arg, menuw=menuw)
!
def eventhandler(self, event, menuw=None):
***************
*** 345,349 ****
simple eventhandler for an item
"""
!
if not menuw:
menuw = self.menuw
--- 290,294 ----
simple eventhandler for an item
"""
!
if not menuw:
menuw = self.menuw
***************
*** 352,356 ****
if p(event, self, menuw):
return True
!
# give the event to the next eventhandler in the list
if self.parent:
--- 297,301 ----
if p(event, self, menuw):
return True
!
# give the event to the next eventhandler in the list
if self.parent:
***************
*** 373,377 ****
return True
return False
!
def __getitem__(self, attr):
--- 318,322 ----
return True
return False
!
def __getitem__(self, attr):
***************
*** 414,418 ****
if attr[:7] == 'parent(' and attr[-1] == ')' and self.parent:
return self.parent[attr[7:-1]]
!
if attr[:4] == 'len(' and attr[-1] == ')':
r = None
--- 359,363 ----
if attr[:7] == 'parent(' and attr[-1] == ')' and self.parent:
return self.parent[attr[7:-1]]
!
if attr[:4] == 'len(' and attr[-1] == ')':
r = None
***************
*** 441,458 ****
- def getattr(self, attr):
- """
- wrapper for __getitem__ to return the attribute as string or
- an empty string if the value is 'None'
- """
- if attr[:4] == 'len(' and attr[-1] == ')':
- return self.__getitem__(attr)
- else:
- r = self.__getitem__(attr)
- if r == None:
- return ''
- return Unicode(r)
-
-
def delete(self):
"""
--- 386,389 ----
***************
*** 460,465 ****
"""
self.parent = None
!
!
def __del__(self):
"""
--- 391,396 ----
"""
self.parent = None
!
!
def __del__(self):
"""
***************
*** 479,483 ****
self.type = type
Item.__init__(self, parent)
!
def set_url(self, url, info=True, search_image=True):
--- 410,414 ----
self.type = type
Item.__init__(self, parent)
!
def set_url(self, url, info=True, search_image=True):
***************
*** 496,503 ****
self.mimetype = '' # extention or mode
return
!
if url.find('://') == -1:
self.url = 'file://' + url
!
self.files = FileInformation()
if self.media:
--- 427,434 ----
self.mimetype = '' # extention or mode
return
!
if url.find('://') == -1:
self.url = 'file://' + url
!
self.files = FileInformation()
if self.media:
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog