original_docstring: Special-case package directory imports.
docstring: Special-case package directory imports.
docstring_tokens: Special - case package directory imports .
code: def load_module(self, name, stuff):
          """Special-case package directory imports."""
          file, filename, (suff, mode, type) = stuff
          path = None
          module = None
          if type == imp.PKG_DIRECTORY:
              # try first importing it as Python PKG_DIRECTORY
              stuff = self.find_module_in_dir("__init__", filename, 0)
              mfiles = get_mfiles(filename)
              if stuff is not None:
                  file = stuff[0]             # package/__init__.py
                  path = [filename]
              elif mfiles:
                  # this is a directory with mfiles
                  # create a new module and fill it with mfunctions
                  module = imp.new_module(filename)
                  for x in mfiles:
                      #setattr(module, x, load_mfunction(filename, x))
                      # all mfiles are considered source, the m2py compilation
                      # stuff is in the load_source function
                      mfunc_name = splitext(split(x)[1])[0]
                      mfile = ihooks.ModuleLoader.load_module(self, mfunc_name, 
                                      (open(x, 'U'), x, ('', '', PY_SOURCE)))
                      setattr(module, mfunc_name, getattr(mfile, mfunc_name, None))
          
          if module is None:
              try:                            # let superclass handle the rest
                  module = ihooks.ModuleLoader.load_module(self, name, stuff)
              finally:
                  if file:
                      file.close()
              if path:
                  module.__path__ = path      # necessary for pkg.module imports
          return module
code_tokens: def load_module ( self , name , stuff ) : file , filename , ( suff , mode , type ) = stuff path = None module = None if type == imp . PKG_DIRECTORY : stuff = self . find_module_in_dir ( "__init__" , filename , 0 ) mfiles = get_mfiles ( filename ) if stuff is not None : file = stuff [ 0 ] path = [ filename ] elif mfiles : module = imp . new_module ( filename ) for x in mfiles : mfunc_name = splitext ( split ( x ) [ 1 ] ) [ 0 ] mfile = ihooks . ModuleLoader . load_module ( self , mfunc_name , ( open ( x , 'U' ) , x , ( '' , '' , PY_SOURCE ) ) ) setattr ( module , mfunc_name , getattr ( mfile , mfunc_name , None ) ) if module is None : try : module = ihooks . ModuleLoader . load_module ( self , name , stuff ) finally : if file : file . close ( ) if path : module . __path__ = path return module
short_docstring: Special-case package directory imports.
short_docstring_tokens: Special - case package directory imports .
comment: """Special-case package directory imports."""$SEP$# try first importing it as Python PKG_DIRECTORY
  $SEP$# package/__init__.py
  $SEP$# this is a directory with mfiles
  $SEP$# create a new module and fill it with mfunctions
  $SEP$#setattr(module, x, load_mfunction(filename, x))
  $SEP$# all mfiles are considered source, the m2py compilation
  $SEP$# stuff is in the load_source function
  $SEP$# let superclass handle the rest
  $SEP$# necessary for pkg.module imports
  