diff --git a/Solverz/__init__.py b/Solverz/__init__.py index df6df46..1f43a57 100644 --- a/Solverz/__init__.py +++ b/Solverz/__init__.py @@ -11,7 +11,7 @@ from Solverz.utilities.profile import count_time from Solverz.variable.ssymbol import Var, AliasVar from Solverz.model.basic import Model -from Solverz.num_api.user_function_parser import save_module_paths, reset_module_paths +from Solverz.num_api.user_function_parser import add_my_module, reset_my_module_paths from importlib.metadata import version, PackageNotFoundError diff --git a/Solverz/num_api/module_parser.py b/Solverz/num_api/module_parser.py index f2f6534..86709d6 100644 --- a/Solverz/num_api/module_parser.py +++ b/Solverz/num_api/module_parser.py @@ -18,9 +18,9 @@ warnings.warn(f'Failed to import num api from SolMuseum: {e}') # parse user defined functions -from .user_function_parser import load_module_paths +from .user_function_parser import load_my_module_paths -user_module_paths = load_module_paths() +user_module_paths = load_my_module_paths() if user_module_paths: print('User module detected.') import os, sys diff --git a/Solverz/num_api/user_function_parser.py b/Solverz/num_api/user_function_parser.py index e262234..247ccd3 100644 --- a/Solverz/num_api/user_function_parser.py +++ b/Solverz/num_api/user_function_parser.py @@ -1,7 +1,5 @@ import os from pathlib import Path -import sys -import importlib.util def validate_module_paths(paths): @@ -32,7 +30,7 @@ def validate_module_paths(paths): return valid_paths -def save_module_paths(paths, filename='user_modules.txt'): +def add_my_module(paths, filename='user_modules.txt'): """ Save user-provided module paths to a specified file, but validate the paths before saving. If a path already exists in the file, it will not be added again. @@ -72,7 +70,7 @@ def save_module_paths(paths, filename='user_modules.txt'): existing_paths.add(path) -def load_module_paths(filename='user_modules.txt'): +def load_my_module_paths(filename='user_modules.txt'): """ Load module paths from a specified file in the .Solverz directory in the user's home directory. @@ -94,7 +92,7 @@ def load_module_paths(filename='user_modules.txt'): return paths -def reset_module_paths(filename='user_modules.txt'): +def reset_my_module_paths(filename='user_modules.txt'): """ Reset the user_modules.txt file by clearing its content.