mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #2492 from pypeclub/bugfix/OP-2332_General-Modules-import-return-fix
General: Modules import function output fix
This commit is contained in:
commit
751ccd5e5f
1 changed files with 7 additions and 9 deletions
|
|
@ -49,32 +49,30 @@ def modules_from_path(folder_path):
|
|||
|
||||
Arguments:
|
||||
path (str): Path to folder containing python scripts.
|
||||
return_crasher (bool): Crashed module paths with exception info
|
||||
will be returned too.
|
||||
|
||||
Returns:
|
||||
list, tuple: List of modules when `return_crashed` is False else tuple
|
||||
with list of modules at first place and tuple of path and exception
|
||||
info at second place.
|
||||
tuple<list, list>: First list contains successfully imported modules
|
||||
and second list contains tuples of path and exception.
|
||||
"""
|
||||
crashed = []
|
||||
modules = []
|
||||
output = (modules, crashed)
|
||||
# Just skip and return empty list if path is not set
|
||||
if not folder_path:
|
||||
return modules
|
||||
return output
|
||||
|
||||
# Do not allow relative imports
|
||||
if folder_path.startswith("."):
|
||||
log.warning((
|
||||
"BUG: Relative paths are not allowed for security reasons. {}"
|
||||
).format(folder_path))
|
||||
return modules
|
||||
return output
|
||||
|
||||
folder_path = os.path.normpath(folder_path)
|
||||
|
||||
if not os.path.isdir(folder_path):
|
||||
log.warning("Not a directory path: {}".format(folder_path))
|
||||
return modules
|
||||
return output
|
||||
|
||||
for filename in os.listdir(folder_path):
|
||||
# Ignore files which start with underscore
|
||||
|
|
@ -101,7 +99,7 @@ def modules_from_path(folder_path):
|
|||
)
|
||||
continue
|
||||
|
||||
return modules, crashed
|
||||
return output
|
||||
|
||||
|
||||
def recursive_bases_from_class(klass):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue