parameters: (dir)
docstring: Load plugins from C{dir}.
docstring_summary: Load plugins from C{dir}.
docstring_tokens: Load plugins from C { dir } .
function: def load_plugins(dir):
      '''Load plugins from C{dir}.'''
      sys_path = sys.path
      cwd = os.getcwd()
      dir = os.path.abspath(os.path.normpath(dir))
      TRACE('* load_plugins from %s' % dir)
      os.chdir(dir)
      sys.path = [dir] + sys_path
      try:                                # try/finally shield
          ff_py = glob.glob('[!_]*.py')
          for f in ff_py:
              name = os.path.splitext(f)[0]
              TRACE('* __import__ %s', name)
              try:
                  __import__(name, globals(), locals(), ['*'])
              except ImportError:
                  logger.exception('importing %s failed', name)
          ff_crx = glob.glob('*.crx')
          for crx in ff_crx:
              TRACE('* load_crx %s', crx)
              try:
                  load_crx(crx)
              except:
                  logger.exception('parsing CRX file %s failed', crx)
          dirs = glob.glob('*/')
          for dir in dirs:
              if os.path.isfile(os.path.join(dir, '__init__.py')):
                  TRACE('* import __init__.py in %s', dir)
                  try:
                      __import__(dir, globals(), locals(), ['*'])
                  except ImportError:
                      logger.exception('importing __init__.py failed')
      finally:
          sys.path = sys_path
          os.chdir(cwd)
function_tokens: def load_plugins ( dir ) : sys_path = sys . path cwd = os . getcwd ( ) dir = os . path . abspath ( os . path . normpath ( dir ) ) TRACE ( '* load_plugins from %s' % dir ) os . chdir ( dir ) sys . path = [ dir ] + sys_path try : # try/finally shield ff_py = glob . glob ( '[!_]*.py' ) for f in ff_py : name = os . path . splitext ( f ) [ 0 ] TRACE ( '* __import__ %s' , name ) try : __import__ ( name , globals ( ) , locals ( ) , [ '*' ] ) except ImportError : logger . exception ( 'importing %s failed' , name ) ff_crx = glob . glob ( '*.crx' ) for crx in ff_crx : TRACE ( '* load_crx %s' , crx ) try : load_crx ( crx ) except : logger . exception ( 'parsing CRX file %s failed' , crx ) dirs = glob . glob ( '*/' ) for dir in dirs : if os . path . isfile ( os . path . join ( dir , '__init__.py' ) ) : TRACE ( '* import __init__.py in %s' , dir ) try : __import__ ( dir , globals ( ) , locals ( ) , [ '*' ] ) except ImportError : logger . exception ( 'importing __init__.py failed' ) finally : sys . path = sys_path os . chdir ( cwd )