| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- """
- MIT License
- Copyright (c) 2024 TheHamkerCat
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- """
- import glob
- import importlib
- import sys
- from os.path import basename, dirname, isfile
- from wbb import MOD_LOAD, MOD_NOLOAD
- def __list_all_modules():
- # This generates a list of modules in this
- # folder for the * in __main__ to work.
- mod_paths = glob.glob(dirname(__file__) + "/*.py")
- all_modules = [
- basename(f)[:-3]
- for f in mod_paths
- if isfile(f)
- and f.endswith(".py")
- and not f.endswith("__init__.py")
- and not f.endswith("__main__.py")
- ]
- if MOD_LOAD or MOD_NOLOAD:
- to_load = MOD_LOAD
- if to_load:
- if not all(
- any(mod == module_name for module_name in all_modules)
- for mod in to_load
- ):
- sys.exit()
- else:
- to_load = all_modules
- if MOD_NOLOAD:
- return [item for item in to_load if item not in MOD_NOLOAD]
- return to_load
- return all_modules
- print("[INFO]: IMPORTING MODULES")
- importlib.import_module("wbb.modules.__main__")
- ALL_MODULES = sorted(__list_all_modules())
- __all__ = ALL_MODULES + ["ALL_MODULES"]
|