Skip to content

Commit

Permalink
Added load_module method to helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-mora committed Aug 14, 2019
1 parent 4372d43 commit 4271f16
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import re
import string
import sys
import importlib.util


# Try to find and import the settings.py config file
Expand Down Expand Up @@ -160,3 +161,13 @@ def validate_port(port_number):
return False
except ValueError:
return False


def load_module(module_path):
"""
Takes module path, return module object
"""
spec = importlib.util.spec_from_file_location(module_path, module_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module

0 comments on commit 4271f16

Please sign in to comment.