opynsim.config#
- opynsim.config.append_search_path(search_path: str | os.PathLike) None#
Appends
search_pathto the end (lowest-priority) of the global search path list (seeget_search_paths()).If an existing entry in the global search path list lexicographically matches
search_path, it is removed to prevent duplicate entries.search_pathdoes not need to exist on the filesystem.
- opynsim.config.get_log_level() int#
Returns the current global logging level for OPynSim. The default log level is
logging.WARNING.If the logger has been misconfigured (e.g. because the log level was edited via Python, rather than via
opynsim.set_log_level()) then the value returned by this function may not matchlogger.getLogger("opynsim").level. Seeset_log_level()for more details.- Returns:
A logging level integer that’s compatible with the Python (
logging) module such aslogging.DEBUG,logging.INFO,logging.WARNING,logging.ERROR, orlogging.CRITICALsee Python’s Logging Levels documentation for more information on the logging levels.- Return type:
int
- opynsim.config.get_search_paths() list[pathlib.Path]#
Returns a copy of the current global search paths used to resolve filesystem resources, ordered from highest to lowest priority.
When OPynSim resolves a relative
path, it uses a context-dependentbase_path(e.g., the directory containing the current model file) and probes locations in this order:If
pathis absolute: Probes onlypathIf
pathis relative: For eachentryinget_search_path(), probe(base_path / entry / path).
Notably, if an
entryis absolute,(base_path / entry / path) == (entry / path), so thebase_pathis ignored for that entry.When a resource cannot be found via probing, the consequences are context-dependent. For example, a mesh implementation that fails to find a mesh file may choose to ignore the failure, generate a debug/error mesh, or throw an exception.
The returned paths will be lexicographically unique, but entries may not be be behaviorally unique. For example,
pathlib.Path("Geometry") == pathlib.Path("geometry")isTrueon Windows butFalseon macOS and Linux. Regardless, the OPynSim API for search paths checks and compares the lexicographic representation.
- opynsim.config.prepend_search_path(search_path: str | os.PathLike) None#
Prepends
search_pathto the start (highest-priority) of the global search path list (seeget_search_paths()).If an existing entry in the global search path list lexicographically matches
search_path, it is removed to prevent duplicate entries.search_pathdoes not need to exist on the filesystem.
- opynsim.config.remove_search_path(search_path: str | os.PathLike) bool#
Returns
Trueif an entry that lexicographically matchessearch_pathwas found and removed from the global search path list.- Parameters:
search_path – The path to remove. It must lexicographically match an entry from
get_search_paths().
- opynsim.config.set_log_level(python_logging_level: int) None#
Sets the global logging level for OPynSim. The default log level is
logging.WARN.opynsimis integrated with Python’s logging API but, for performance reasons, its C++ engine stores an internal log level separately. This function synchronizes the log level of both OPynSim’s Python logger (i.e.logger.getLogger("opynsim")) and the internal C++ log level. Changing only the Python logger can result in a situation where the C++ engine emits (or doesn’t!) log messages that Python logger subsequently drops.- Parameters:
python_logging_level (int) –
A logging level from the Python (
logging) module such aslogging.DEBUG,logging.INFO,logging.WARNING,logging.ERROR, orlogging.CRITICALsee Python’s Logging Levels documentation for more information on the logging levels.