1 """Core modules package for the mudpy engine."""
3 # Copyright (c) 2004-2022 mudpy authors. Permission to use, copy,
4 # modify, and distribute this software is granted under terms
5 # provided in the LICENSE file distributed with this software.
13 """Import/reload some modules (be careful, as this can result in loops)."""
15 # dynamically build module list from package contents
17 for module in mudpy.__spec__.loader.get_resource_reader().contents():
20 # make sure it's a module file, not a directory
21 module.endswith('.py')
23 # don't include this file, we're inside it
24 and module != '__init__.py'):
26 # trim off the .py file extension
27 modules.append(module[:-3])
29 # iterate over the list of module files included in the package
30 for module in modules:
32 # attempt to reload the module, assuming it was probably imported
35 importlib.reload(getattr(mudpy, module))
37 # must not have been, so import it now
38 except AttributeError:
39 importlib.import_module("mudpy.%s" % module)