mirror of https://github.com/VLSIDA/OpenRAM.git
add error message when configuration files are not valid python module names
This commit is contained in:
parent
5833728889
commit
9eb2f3c0e6
|
|
@ -295,6 +295,14 @@ def read_config(config_file, is_unit_test=True):
|
||||||
dir_name = os.path.dirname(config_file)
|
dir_name = os.path.dirname(config_file)
|
||||||
module_name = os.path.basename(config_file)
|
module_name = os.path.basename(config_file)
|
||||||
|
|
||||||
|
# Check that the module name adheres to Python's module naming conventions.
|
||||||
|
# This will assist the user in interpreting subsequent errors in loading
|
||||||
|
# the module. Valid Python module naming is described here:
|
||||||
|
# https://docs.python.org/3/reference/simple_stmts.html#the-import-statement
|
||||||
|
if not module_name.isidentifier():
|
||||||
|
debug.error("Configuration file name is not a valid Python module name: "
|
||||||
|
"{0}. It should be a valid identifier.".format(module_name))
|
||||||
|
|
||||||
# Prepend the path to avoid if we are using the example config
|
# Prepend the path to avoid if we are using the example config
|
||||||
sys.path.insert(0, dir_name)
|
sys.path.insert(0, dir_name)
|
||||||
# Import the configuration file of which modules to use
|
# Import the configuration file of which modules to use
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue