SHARE
TWEET

Untitled

a guest Apr 24th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2.  
  3. import glob
  4. import sys
  5. import os.path
  6. import importlib
  7. import re
  8.  
  9. this_file = os.path.dirname(os.path.abspath(__file__))
  10.  
  11.  
  12. def load_module():
  13.  
  14.     myself = sys.modules[__name__]
  15.  
  16.     mod_paths = glob.glob(os.path.join(this_file, '*.py'))
  17.     for py_file in mod_paths:
  18.         mod_name = os.path.splitext(os.path.basename(py_file))[0]
  19.         if re.search(".*__init__.*", mod_name) is None:
  20.             mod = importlib.import_module(__name__ + "." + mod_name)
  21.             for m in mod.__dict__.keys():
  22.                 if not m in ['__builtins__', '__doc__', '__file__', '__name__', '__package__']:
  23.                     myself.__dict__[m] = mod.__dict__[m]
  24.  
  25.  
  26. load_module()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top