Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1373/src

Modified Files:
        playlist.py 
Log Message:
make sure there is self.info and respect coding guidelines

Index: playlist.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/playlist.py,v
retrieving revision 1.80
retrieving revision 1.81
diff -C2 -d -r1.80 -r1.81
*** playlist.py 10 Apr 2005 18:08:13 -0000      1.80
--- playlist.py 11 Apr 2005 17:52:37 -0000      1.81
***************
*** 1,49 ****
  # -*- coding: iso-8859-1 -*-
! # -----------------------------------------------------------------------
! # playlist.py - This is the Freevo playlist reading module. 
! # -----------------------------------------------------------------------
  # $Id$
  #
! # Notes:
! # Todo:        
! #
! # -----------------------------------------------------------------------
! # $Log$
! # Revision 1.80  2005/04/10 18:08:13  dischi
! # switch to new mediainfo module
! #
! # Revision 1.79  2004/11/20 18:22:59  dischi
! # use python logger module for debug
! #
! # Revision 1.78  2004/11/01 20:14:14  dischi
! # fix debug
! #
! # Revision 1.77  2004/08/29 18:37:30  dischi
! # make playlist an mediaitem
! #
! # Revision 1.76  2004/08/26 15:26:49  dischi
! # add code to do some memory debugging
! #
! # Revision 1.75  2004/08/23 20:36:42  dischi
! # rework application handling
! #
! # Revision 1.74  2004/08/01 10:55:08  dischi
! # do not show the menu, it can do that itself
! #
! # Revision 1.73  2004/07/26 18:10:16  dischi
! # move global event handling to eventhandler.py
! #
! # Revision 1.72  2004/07/10 12:33:36  dischi
! # header cleanup
! #
! # Revision 1.71  2004/06/28 15:51:21  dischi
! # catch IOError
  #
! # Revision 1.70  2004/05/09 16:44:13  dischi
! # fix crash in m3u parsing
  #
- # -----------------------------------------------------------------------
- # 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,15 ----
  # -*- coding: iso-8859-1 -*-
! # 
-----------------------------------------------------------------------------
! # playlist.py - This is the Freevo playlist reading module.
! # 
-----------------------------------------------------------------------------
  # $Id$
  #
! # 
-----------------------------------------------------------------------------
! # Freevo - A Home Theater PC framework
! # Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
  #
! # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
! # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
  #
  # Please see the file freevo/Docs/CREDITS for a complete list of authors.
  #
***************
*** 62,73 ****
  # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  #
! # ----------------------------------------------------------------------- */
! 
  
  import random
  import os
  import re
  import copy
  
  import config
  import menu
--- 28,41 ----
  # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  #
! # 
-----------------------------------------------------------------------------
  
+ # python imports
  import random
  import os
  import re
  import copy
+ import logging
  
+ # freevo imports
  import config
  import menu
***************
*** 75,79 ****
  import eventhandler
  import plugin
! from mediadb import FileListing
  
  from event import *
--- 43,47 ----
  import eventhandler
  import plugin
! import mediadb
  
  from event import *
***************
*** 81,89 ****
  from gui import ProgressBox
  
! import logging
  log = logging.getLogger()
  
- class Playlist(MediaItem):
  
      def __init__(self, name='', playlist=[], parent=None, display_type=None,
                   random=False, build=False, autoplay=False, repeat=False):
--- 49,61 ----
  from gui import ProgressBox
  
! # get logging object
  log = logging.getLogger()
  
  
+ class Playlist(MediaItem):
+     """
+     Class for playlists. A playlist can be created with a list of items or a
+     filename containing the playlist.
+     """
      def __init__(self, name='', playlist=[], parent=None, display_type=None,
                   random=False, build=False, autoplay=False, repeat=False):
***************
*** 114,121 ****
  
          self.background_playlist = None
          if build:
              self.build()
! 
!         self.random = random
  
  
--- 86,96 ----
  
          self.background_playlist = None
+         self.random = random
+ 
          if build:
              self.build()
!         else:
!             # create a basic info object
!             self.info = mediadb.ItemInfo('', '', {})
  
  
***************
*** 135,143 ****
          try:
              playlist_lines_dos = map(lambda l: l.strip(), lines)
!             playlist_lines     = filter(lambda l: l[0] != '#', 
playlist_lines_dos)
          except IndexError:
              log.warning('Bad m3u playlist file "%s"' % plsname)
              return 0
!         
          (curdir, playlistname) = os.path.split(plsname)
          for line in playlist_lines:
--- 110,118 ----
          try:
              playlist_lines_dos = map(lambda l: l.strip(), lines)
!             playlist_lines = filter(lambda l: l[0] != '#', playlist_lines_dos)
          except IndexError:
              log.warning('Bad m3u playlist file "%s"' % plsname)
              return 0
! 
          (curdir, playlistname) = os.path.split(plsname)
          for line in playlist_lines:
***************
*** 146,150 ****
              if os.path.exists(os.path.join(curdir,line)):
                  self.playlist.append(os.path.join(curdir,line))
!             
  
      def read_pls(self, plsname):
--- 121,125 ----
              if os.path.exists(os.path.join(curdir,line)):
                  self.playlist.append(os.path.join(curdir,line))
! 
  
      def read_pls(self, plsname):
***************
*** 176,180 ****
              if os.path.exists(os.path.join(curdir,line)):
                  self.playlist.append(os.path.join(curdir,line))
!             
  
  
--- 151,155 ----
              if os.path.exists(os.path.join(curdir,line)):
                  self.playlist.append(os.path.join(curdir,line))
! 
  
  
***************
*** 206,210 ****
  
          """
!         Here's where we parse the line.  See the format above.  
          TODO:  Make the search case insensitive
          """
--- 181,185 ----
  
          """
!         Here's where we parse the line.  See the format above.
          TODO:  Make the search case insensitive
          """
***************
*** 250,254 ****
              self.suffixlist += p.suffix()
              self.get_plugins.append(p)
!                 
          if isstring(playlist):
              self.set_url(playlist)
--- 225,229 ----
              self.suffixlist += p.suffix()
              self.get_plugins.append(p)
! 
          if isstring(playlist):
              self.set_url(playlist)
***************
*** 276,279 ****
--- 251,257 ----
          # self.playlist is a list of Items or strings (filenames)
          if not isstring(playlist):
+             # create a basic info object
+             self.info = mediadb.ItemInfo('', '', {})
+ 
              for i in playlist:
                  if isinstance(i, Item):
***************
*** 300,304 ****
  
          self.__build__ = True
!                 
  
      def randomize(self):
--- 278,282 ----
  
          self.__build__ = True
! 
  
      def randomize(self):
***************
*** 313,317 ****
              self.playlist += [ element ]
  
!         
      def actions(self):
          """
--- 291,295 ----
              self.playlist += [ element ]
  
! 
      def actions(self):
          """
***************
*** 322,326 ****
  
          play_item = ( self.play, _('Play') )
!         
          if self.autoplay:
              items = [ play_item ] + items
--- 300,304 ----
  
          play_item = ( self.play, _('Play') )
! 
          if self.autoplay:
              items = [ play_item ] + items
***************
*** 332,336 ****
  
          return items
!     
  
      def browse(self, arg=None, menuw=None):
--- 310,314 ----
  
          return items
! 
  
      def browse(self, arg=None, menuw=None):
***************
*** 345,349 ****
                  files.append(item)
  
!         listing = FileListing(files)
          if listing.num_changes > 10:
              text = _('Scanning playlist, be patient...')
--- 323,327 ----
                  files.append(item)
  
!         listing = mediadb.FileListing(files)
          if listing.num_changes > 10:
              text = _('Scanning playlist, be patient...')
***************
*** 354,358 ****
          elif listing.num_changes:
              listing.update()
!         
          items = []
  
--- 332,336 ----
          elif listing.num_changes:
              listing.update()
! 
          items = []
  
***************
*** 360,364 ****
              if not callable(item):
                  # get a real item
!                 listing = FileListing([item])
                  if listing.num_changes:
                      listing.update()
--- 338,342 ----
              if not callable(item):
                  # get a real item
!                 listing = mediadb.FileListing([item])
                  if listing.num_changes:
                      listing.update()
***************
*** 369,373 ****
  
          self.playlist = items
!         
          if self.random:
              self.randomize()
--- 347,351 ----
  
          self.playlist = items
! 
          if self.random:
              self.randomize()
***************
*** 375,379 ****
          moviemenu = menu.Menu(self.name, self.playlist)
          menuw.pushmenu(moviemenu)
!         
  
      def random_play(self, arg=None, menuw=None):
--- 353,357 ----
          moviemenu = menu.Menu(self.name, self.playlist)
          menuw.pushmenu(moviemenu)
! 
  
      def random_play(self, arg=None, menuw=None):
***************
*** 385,389 ****
                   repeat=self.repeat).play(arg,menuw)
  
!         
      def play(self, arg=None, menuw=None):
          """
--- 363,367 ----
                   repeat=self.repeat).play(arg,menuw)
  
! 
      def play(self, arg=None, menuw=None):
          """
***************
*** 397,401 ****
              log.warning('empty playlist')
              return False
!         
          if not arg or arg != 'next':
              # first start
--- 375,379 ----
              log.warning('empty playlist')
              return False
! 
          if not arg or arg != 'next':
              # first start
***************
*** 425,429 ****
  
  
!         if not hasattr(self.current_item, 'actions') or not 
self.current_item.actions():
              # skip item
              pos = self.playlist.index(self.current_item)
--- 403,408 ----
  
  
!         if not hasattr(self.current_item, 'actions') or \
!                not self.current_item.actions():
              # skip item
              pos = self.playlist.index(self.current_item)
***************
*** 442,446 ****
          else:
              self.current_item.actions()[0][0](menuw=menuw)
!         
  
      def cache_next(self):
--- 421,425 ----
          else:
              self.current_item.actions()[0][0](menuw=menuw)
! 
  
      def cache_next(self):
***************
*** 467,471 ****
                  except OSError:
                      pass
!         
  
      def eventhandler(self, event, menuw=None):
--- 446,450 ----
                  except OSError:
                      pass
! 
  
      def eventhandler(self, event, menuw=None):
***************
*** 477,486 ****
          if event == PLAY_END:
              if self.current_item and self.current_item.type == 'audio':
!                 eventhandler.post(Event(AUDIO_LOG, 
arg=self.current_item.filename))
  
          if event in (INPUT_1, INPUT_2, INPUT_3, INPUT_4, INPUT_5) and \
!                event.arg and self.current_item and 
hasattr(self.current_item,'type'):
              if (self.current_item.type == 'audio'):
!                 
eventhandler.post(Event(RATING,(event.arg,self.current_item.filename)))
  
  
--- 456,468 ----
          if event == PLAY_END:
              if self.current_item and self.current_item.type == 'audio':
!                 e = Event(AUDIO_LOG, arg=self.current_item.filename)
!                 eventhandler.post(e)
  
          if event in (INPUT_1, INPUT_2, INPUT_3, INPUT_4, INPUT_5) and \
!                event.arg and self.current_item and \
!                hasattr(self.current_item,'type'):
              if (self.current_item.type == 'audio'):
!                 e = Event(RATING,(event.arg, self.current_item.filename))
!                 eventhandler.post(e)
  
  
***************
*** 491,497 ****
              self.repeat = not self.repeat
              if self.repeat:
!                 eventhandler.post(Event(OSD_MESSAGE, arg=_('playlist repeat 
on')))
              else:
!                 eventhandler.post(Event(OSD_MESSAGE, arg=_('playlist repeat 
off')))
  
          if event in ( PLAYLIST_NEXT, PLAY_END, USER_END) \
--- 473,480 ----
              self.repeat = not self.repeat
              if self.repeat:
!                 arg = _('playlist repeat on')
              else:
!                 arg = arg=_('playlist repeat off')
!             eventhandler.post(Event(OSD_MESSAGE, arg=arg))
  
          if event in ( PLAYLIST_NEXT, PLAY_END, USER_END) \
***************
*** 507,513 ****
                  return True
              elif event == PLAYLIST_NEXT:
!                 eventhandler.post(Event(OSD_MESSAGE, arg=_('no next item in 
playlist')))
  
-                 
          # end and no next item
          if event in (PLAY_END, USER_END, STOP):
--- 490,497 ----
                  return True
              elif event == PLAYLIST_NEXT:
!                 e = Event(OSD_MESSAGE, arg=_('no next item in playlist'))
!                 eventhandler.post(e)
! 
  
          # end and no next item
          if event in (PLAY_END, USER_END, STOP):
***************
*** 516,520 ****
              self.current_item = None
              return True
!             
  
          if event == PLAYLIST_PREV and self.current_item and self.playlist:
--- 500,504 ----
              self.current_item = None
              return True
! 
  
          if event == PLAYLIST_PREV and self.current_item and self.playlist:
***************
*** 532,536 ****
                  return True
              else:
!                 eventhandler.post(Event(OSD_MESSAGE, arg=_('no previous item 
in playlist')))
  
          # give the event to the next eventhandler in the list
--- 516,521 ----
                  return True
              else:
!                 e = Event(OSD_MESSAGE, arg=_('no previous item in playlist'))
!                 eventhandler.post(e)
  
          # give the event to the next eventhandler in the list
***************
*** 544,550 ****
          MediaItem.delete(self)
          self.playlist = []
-         
  
!     
  
  
--- 529,535 ----
          MediaItem.delete(self)
          self.playlist = []
  
! 
! 
  
  
***************
*** 566,570 ****
          return config.PLAYLIST_SUFFIX + config.IMAGE_SSHOW_SUFFIX
  
!     
      def get(self, parent, listing):
          """
--- 551,555 ----
          return config.PLAYLIST_SUFFIX + config.IMAGE_SSHOW_SUFFIX
  
! 
      def get(self, parent, listing):
          """



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to