-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`loadModule` loads the file directly instead of searching in a directory.
- Loading branch information
Showing
2 changed files
with
8 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
#!/usr/bin/env python | ||
import os.path as path | ||
import os.path as osp | ||
import sys | ||
from importlib import util as ilu, machinery as ilm | ||
from importlib import machinery as ilm | ||
|
||
def main(): | ||
if not (bt := sys.modules.get("bt", None)): | ||
spec = ilm.PathFinder().find_spec("bt", [path.dirname(path.dirname(path.realpath(__file__)))]) | ||
bt = ilu.module_from_spec(spec) | ||
sys.modules[bt.__name__] = bt | ||
spec.loader.exec_module(bt) | ||
def loadModule(name, path): | ||
return ilm.SourceFileLoader(name, path).load_module() | ||
|
||
bt.main() | ||
def main(): | ||
(sys.modules.get("bt", None) or loadModule("bt", osp.join(osp.dirname(osp.realpath(__file__)), "__init__.py"))).main(loadModule) | ||
|
||
if __name__ == "__main__": main() |