From f8177ef58db80ffcd53fb5e211d98eb24fa60dbe Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Tue, 14 Dec 2021 11:31:16 +1000 Subject: [PATCH] Revert "Expose tools.toml config file to users." This reverts commit 01bb09cb7d9bef2413c070308ed8b1de50aec935. - Problem is, the later changes of the config file in eris aren't seen by the user. --- eris/eris/__main__.py | 11 ++++------- eris/eris/tools.py | 11 +++-------- eris/eris/{eris-tools.toml => tools.toml} | 1 + eris/setup.py | 2 +- 4 files changed, 9 insertions(+), 16 deletions(-) rename eris/eris/{eris-tools.toml => tools.toml} (99%) diff --git a/eris/eris/__main__.py b/eris/eris/__main__.py index 3fe6c9b..618e1d8 100755 --- a/eris/eris/__main__.py +++ b/eris/eris/__main__.py @@ -1073,16 +1073,13 @@ def manage_cache(root_path): timestamp_path = os.path.join(cache_path, "creation_time") if os.path.exists(cache_path): timestamp = os.stat(timestamp_path).st_mtime - is_updated = False - for resource_path in ["__main__.py", "tools.py"]: + for resource_path in ["__main__.py", "tools.py", "tools.toml"]: with importlib.resources.path(eris, resource_path) as resource: if resource.stat().st_mtime > timestamp: - is_updated = True + print("Eris has been updated, so clearing the cache and" + " recalculating all results…") + shutil.rmtree(cache_path) break - is_updated = is_updated or os.stat(tools.CONFIG_PATH).st_mtime > timestamp - if is_updated: - print("Eris has been updated, so clearing the cache and recalculating all results…") - shutil.rmtree(cache_path) if not os.path.exists(cache_path): os.mkdir(cache_path) open(timestamp_path, "w").close() diff --git a/eris/eris/tools.py b/eris/eris/tools.py index 09001e4..d9424df 100755 --- a/eris/eris/tools.py +++ b/eris/eris/tools.py @@ -460,13 +460,8 @@ def make_tool_function(dependencies, command, url=None, error_status=None, elinks, git_diff, git_blame = None, None, None # For linters. - - -CONFIG_PATH = os.path.join(os.environ["HOME"], ".config", "eris-tools.toml") -if not os.path.exists(CONFIG_PATH): - with importlib.resources.path(eris, "eris-tools.toml") as toml_path: - shutil.copy(toml_path, CONFIG_PATH) -tools_toml = toml.load(CONFIG_PATH) +with importlib.resources.open_text(eris, "tools.toml") as tools_toml_file: + tools_toml = toml.load(tools_toml_file) tools_for_extensions = tools_toml["tools_for_extensions"] del tools_toml["tools_for_extensions"] for tool_name, tool_toml in tools_toml.items(): @@ -728,7 +723,7 @@ def tool_name_colored(tool, path): if __name__ == "__main__": # Let tools be tested individually... # ./tools.py - # e.g. ./tools.py contents README.md + # e.g. ./tools.py contents tools.toml tool_name, path = sys.argv[1:3] tool = locals()[tool_name] valid_tools = tools_for_path(path) diff --git a/eris/eris/eris-tools.toml b/eris/eris/tools.toml similarity index 99% rename from eris/eris/eris-tools.toml rename to eris/eris/tools.toml index 2e4e559..eaff776 100644 --- a/eris/eris/eris-tools.toml +++ b/eris/eris/tools.toml @@ -4,6 +4,7 @@ tools_for_extensions = [ [["py"], ["python_syntax", "python_unittests", "pytest", "pydoc", "mypy", "python_coverage", "pycodestyle", "pydocstyle", "pyflakes", "pylint", "python_gut", "python_mccabe", "bandit"]], +# [["pyc"], ["pydisasm"]], [["pl", "pm", "t"], ["perl_syntax", "perldoc"]], [["p6", "pm6"], ["perl6_syntax"]], [["pod", "pod6"], ["perldoc"]], diff --git a/eris/setup.py b/eris/setup.py index c0fb8b8..3111a0b 100755 --- a/eris/setup.py +++ b/eris/setup.py @@ -16,7 +16,7 @@ setup(name="eris", license="Artistic 2.0", packages=["eris"], py_modules=["lscolors", "sorted_collection"], - package_data={"eris": ["LS_COLORS.sh", "eris-tools.toml"]}, + package_data={"eris": ["LS_COLORS.sh", "tools.toml"]}, entry_points={"console_scripts": ["eris=eris.__main__:entry_point", "eris-worker=eris.worker:main", "eris-webserver=eris.webserver:main",