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

Modified Files:
        plugin.py 
Log Message:
respect coding style

Index: plugin.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugin.py,v
retrieving revision 1.80
retrieving revision 1.81
diff -C2 -d -r1.80 -r1.81
*** plugin.py   18 Dec 2004 18:08:39 -0000      1.80
--- plugin.py   8 Jan 2005 11:52:53 -0000       1.81
***************
*** 1,42 ****
  # -*- coding: iso-8859-1 -*-
! # -----------------------------------------------------------------------
  # plugin.py - Plugin interface
! # -----------------------------------------------------------------------
  # $Id$
  #
! # Notes: This file handles the Freevo plugin interface
! # Todo:  Maybe split plugin class definitions into an extra file
! #
! # -----------------------------------------------------------------------
! # $Log$
! # Revision 1.80  2004/12/18 18:08:39  dischi
! # add 'database()' function to mimetypes
! #
! # Revision 1.79  2004/12/18 13:41:28  dischi
! # call notifier.step() on init
! #
! # Revision 1.78  2004/11/21 11:12:06  dischi
! # some logging updates
! #
! # Revision 1.77  2004/10/09 16:24:54  dischi
! # add function to return number of plugins, activate callback change
! #
! # Revision 1.76  2004/10/08 20:18:17  dischi
! # new eventhandler <-> plugin interface
! #
! # Revision 1.75  2004/10/06 19:16:29  dischi
! # o rename __variable__ to _variable
! # o notifier support
! # o use 80 chars/line max
  #
! # Revision 1.74  2004/09/27 18:41:06  dischi
! # add input plugin class
  #
! # Revision 1.73  2004/08/29 18:38:15  dischi
! # make cache helper work again
  #
- # -----------------------------------------------------------------------
- # 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,19 ----
  # -*- coding: iso-8859-1 -*-
! # 
-----------------------------------------------------------------------------
  # plugin.py - Plugin interface
! # 
-----------------------------------------------------------------------------
  # $Id$
  #
! # This file is the basic plugin interface for Freevo. It defines simple plugin
! # base classes functions to add or remove a plugin. On init it will load all
! # plugins for the given application.
  #
! # 
-----------------------------------------------------------------------------
! # 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.
  #
***************
*** 55,82 ****
  # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  #
! # ----------------------------------------------------------------------- */
! 
  
! import os, sys
! import gettext
  import copy
  
  import notifier
  
  import cleanup
  from event import Event
- 
- import config
  import eventhandler
- import notifier
  
! import logging
  log = logging.getLogger('config')
  
  
- if float(sys.version[0:3]) < 2.3:
-     True  = 1
-     False = 0
- 
  #
  # Some basic plugins known to Freevo.
--- 32,55 ----
  # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  #
! # 
-----------------------------------------------------------------------------
  
! # python imports
! import os
  import copy
+ import logging
  
  import notifier
  
+ # freevo imports
+ import config
  import cleanup
  from event import Event
  import eventhandler
  
! 
! # get logging object
  log = logging.getLogger('config')
  
  
  #
  # Some basic plugins known to Freevo.
***************
*** 96,100 ****
              if not hasattr(config, var):
                  setattr(config, var, val)
!             
      def config(self):
          """
--- 69,74 ----
              if not hasattr(config, var):
                  setattr(config, var, val)
! 
! 
      def config(self):
          """
***************
*** 105,122 ****
          return []
  
-     def translation(self, application):
-         """
-         Loads the gettext translation for this plugin (only this class).
-         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 shutdown(self):
--- 79,82 ----
***************
*** 126,130 ****
          pass
  
!     
  class MainMenuPlugin(Plugin):
      """
--- 86,91 ----
          pass
  
! 
! 
  class MainMenuPlugin(Plugin):
      """
***************
*** 142,145 ****
--- 103,107 ----
  
  
+ 
  class ItemPlugin(Plugin):
      """
***************
*** 151,155 ****
      True, the event won't be passed to other eventhandlers and also not to
      the item itself.
!     
      def eventhandler(self, item, event, menuw=None):
      """
--- 113,117 ----
      True, the event won't be passed to other eventhandlers and also not to
      the item itself.
! 
      def eventhandler(self, item, event, menuw=None):
      """
***************
*** 165,169 ****
          return []
  
!     
  class DaemonPlugin(Plugin):
      """
--- 127,131 ----
          return []
  
! 
  class DaemonPlugin(Plugin):
      """
***************
*** 196,200 ****
          return True
  
!         
  class MimetypePlugin(Plugin):
      """
--- 158,162 ----
          return True
  
! 
  class MimetypePlugin(Plugin):
      """
***************
*** 215,219 ****
          return []
  
!     
      def get(self, parent, files):
          """
--- 177,181 ----
          return []
  
! 
      def get(self, parent, files):
          """
***************
*** 228,232 ****
          """
          return len(self.find_matches(files, self.suffix()))
!             
  
      def dirinfo(self, diritem):
--- 190,194 ----
          """
          return len(self.find_matches(files, self.suffix()))
! 
  
      def dirinfo(self, diritem):
***************
*** 250,254 ****
          return None
  
!     
  class InputPlugin(Plugin):
      """
--- 212,216 ----
          return None
  
! 
  class InputPlugin(Plugin):
      """
***************
*** 339,343 ****
  
      # remove by name
!     r = [] 
      for p in copy.copy(_all_plugins):
          if p[0] == id:
--- 301,305 ----
  
      # remove by name
!     r = []
      for p in copy.copy(_all_plugins):
          if p[0] == id:
***************
*** 367,371 ****
                  return p
      return False
!                 
  
  def get_number():
--- 329,333 ----
                  return p
      return False
! 
  
  def get_number():
***************
*** 381,385 ****
      global _initialized
      global _plugin_basedir
!     
      _initialized = True
      _plugin_basedir = os.environ['FREEVO_PYTHON']
--- 343,347 ----
      global _initialized
      global _plugin_basedir
! 
      _initialized = True
      _plugin_basedir = os.environ['FREEVO_PYTHON']
***************
*** 411,415 ****
  
      # sort plugins in extra function (exec doesn't like to be
!     # in the same function is 'lambda' 
      _sort_plugins()
  
--- 373,377 ----
  
      # sort plugins in extra function (exec doesn't like to be
!     # in the same function is 'lambda'
      _sort_plugins()
  
***************
*** 423,427 ****
      global _initialized
      global _plugin_basedir
!     
      _plugin_basedir = os.environ['FREEVO_PYTHON']
  
--- 385,389 ----
      global _initialized
      global _plugin_basedir
! 
      _plugin_basedir = os.environ['FREEVO_PYTHON']
  
***************
*** 436,444 ****
              del _all_plugins[i]
              break
!         
      # sort plugins in extra function (exec doesn't like to be
!     # in the same function is 'lambda' 
      _sort_plugins()
!     
  
  
--- 398,406 ----
              del _all_plugins[i]
              break
! 
      # sort plugins in extra function (exec doesn't like to be
!     # in the same function is 'lambda'
      _sort_plugins()
! 
  
  
***************
*** 479,483 ****
      return ret
  
!         
  def getbyname(name, multiple_choises=0):
      """
--- 441,445 ----
      return ret
  
! 
  def getbyname(name, multiple_choises=0):
      """
***************
*** 525,529 ****
      return _callbacks[name]
  
!     
  def event(name, arg=None):
      """
--- 487,491 ----
      return _callbacks[name]
  
! 
  def event(name, arg=None):
      """
***************
*** 568,572 ****
          _plugin_type_list[type] = []
      _plugin_type_list[type].append(object)
!     
  
  
--- 530,534 ----
          _plugin_type_list[type] = []
      _plugin_type_list[type].append(object)
! 
  
  
***************
*** 603,607 ****
      return None, None
  
!         
  
  def _load_plugin(name, type, level, args, number):
--- 565,569 ----
      return None, None
  
! 
  
  def _load_plugin(name, type, level, args, number):
***************
*** 609,614 ****
      load the plugin and add it to the lists
      """
!     
!     
      global _plugin_type_list
      global _named_plugins
--- 571,576 ----
      load the plugin and add it to the lists
      """
! 
! 
      global _plugin_type_list
      global _named_plugins
***************
*** 638,642 ****
              log.critical('can\'t locate plugin %s' % name)
              return
!         
      try:
          if not isinstance(name, Plugin):
--- 600,604 ----
              log.critical('can\'t locate plugin %s' % name)
              return
! 
      try:
          if not isinstance(name, Plugin):
***************
*** 661,669 ****
                               'nor set a reason why\nPlease contact the 
plugin'\
                               'author or the freevo list'
!                 log.warning('plugin %s deactivated\n  reason: %s' % (name, 
reason))
                  return
          else:
              p = name
!             
          p._number = number
          p._level = level
--- 623,632 ----
                               'nor set a reason why\nPlease contact the 
plugin'\
                               'author or the freevo list'
!                 log.warning('plugin %s deactivated\n  reason: %s' % \
!                             (name, reason))
                  return
          else:
              p = name
! 
          p._number = number
          p._level = level
***************
*** 683,687 ****
              _add_to_ptl(p._type, p)
  
!         else: 
              if isinstance(p, DaemonPlugin):
                  if hasattr(p, 'poll'):
--- 646,650 ----
              _add_to_ptl(p._type, p)
  
!         else:
              if isinstance(p, DaemonPlugin):
                  if hasattr(p, 'poll'):
***************
*** 694,700 ****
                      else:
                          if p.event_listener:
!                             eventhandler.register(p, 
eventhandler.GENERIC_HANDLER)
                          else:
!                             eventhandler.register(p, 
eventhandler.EVENT_LISTENER)
  
              if isinstance(p, MainMenuPlugin):
--- 657,664 ----
                      else:
                          if p.event_listener:
!                             handler = eventhandler.GENERIC_HANDLER
                          else:
!                             handler = eventhandler.EVENT_LISTENER
!                         eventhandler.register(p, handler)
  
              if isinstance(p, MainMenuPlugin):
***************
*** 711,715 ****
          # register shutdown handler
          cleanup.register( p.shutdown )
!                 
          if p.plugin_name:
              _named_plugins[p.plugin_name] = p
--- 675,679 ----
          # register shutdown handler
          cleanup.register( p.shutdown )
! 
          if p.plugin_name:
              _named_plugins[p.plugin_name] = p



-------------------------------------------------------
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

Reply via email to