Python imp.load_package() Examples
The following are 4
code examples of imp.load_package().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
imp
, or try the search function
.
Example #1
Source File: test_imp.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_load_package(self): import testpkg1 pkg = imp.load_package('libcopy', testpkg1.__path__[0]) self.assertEqual(sys.modules['libcopy'], pkg) pkg = imp.load_package('some_new_pkg', 'some_path_that_does_not_and_never_will_exist') self.assertEqual(sys.modules['some_new_pkg'], pkg)
Example #2
Source File: test_imp.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_load_package(self): import testpkg1 pkg = imp.load_package('libcopy', testpkg1.__path__[0]) self.assertEqual(sys.modules['libcopy'], pkg) with self.assertRaises(AttributeError): # AttributeError: 'NoneType' object has no attribute 'name' imp.load_package('some_new_pkg', 'some_path_that_does_not_and_never_will_exist')
Example #3
Source File: lptenv.py From lpts with GNU General Public License v2.0 | 5 votes |
def setup(base_path, root_module_name="lpt"): if sys.modules.has_key(root_module_name): # already set up return _create_module_and_parents(root_module_name) imp.load_package(root_module_name, base_path) # Allow locally installed third party packages to be found. # This is primarily for the benefit of frontend and tko so that they # may use libraries other than those available as system packages. sys.path.insert(0, os.path.join(base_path, "site-packages"))
Example #4
Source File: init_env.py From lpts with GNU General Public License v2.0 | 5 votes |
def setup(base_path, root_module_name="lpt"): if sys.modules.has_key(root_module_name): # already set up return _create_module_and_parents(root_module_name) imp.load_package(root_module_name, base_path) # Allow locally installed third party packages to be found. # This is primarily for the benefit of frontend and tko so that they # may use libraries other than those available as system packages. sys.path.insert(0, os.path.join(base_path, "site-packages"))