Expose tools.toml config file to users.
- Renamed tools.toml to eris-tools.toml. - Copy eris-tools.toml into ~/.config if it's not already there. - If the config file changes, results are recalculated.
This commit is contained in:
parent
38abb17ab9
commit
01bb09cb7d
4 changed files with 16 additions and 9 deletions
|
|
@ -1073,13 +1073,16 @@ def manage_cache(root_path):
|
||||||
timestamp_path = os.path.join(cache_path, "creation_time")
|
timestamp_path = os.path.join(cache_path, "creation_time")
|
||||||
if os.path.exists(cache_path):
|
if os.path.exists(cache_path):
|
||||||
timestamp = os.stat(timestamp_path).st_mtime
|
timestamp = os.stat(timestamp_path).st_mtime
|
||||||
for resource_path in ["__main__.py", "tools.py", "tools.toml"]:
|
is_updated = False
|
||||||
|
for resource_path in ["__main__.py", "tools.py"]:
|
||||||
with importlib.resources.path(eris, resource_path) as resource:
|
with importlib.resources.path(eris, resource_path) as resource:
|
||||||
if resource.stat().st_mtime > timestamp:
|
if resource.stat().st_mtime > timestamp:
|
||||||
print("Eris has been updated, so clearing the cache and"
|
is_updated = True
|
||||||
" recalculating all results…")
|
|
||||||
shutil.rmtree(cache_path)
|
|
||||||
break
|
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):
|
if not os.path.exists(cache_path):
|
||||||
os.mkdir(cache_path)
|
os.mkdir(cache_path)
|
||||||
open(timestamp_path, "w").close()
|
open(timestamp_path, "w").close()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ tools_for_extensions = [
|
||||||
[["py"], ["python_syntax", "python_unittests", "pytest", "pydoc", "mypy",
|
[["py"], ["python_syntax", "python_unittests", "pytest", "pydoc", "mypy",
|
||||||
"python_coverage", "pycodestyle", "pydocstyle", "pyflakes",
|
"python_coverage", "pycodestyle", "pydocstyle", "pyflakes",
|
||||||
"pylint", "python_gut", "python_mccabe", "bandit"]],
|
"pylint", "python_gut", "python_mccabe", "bandit"]],
|
||||||
# [["pyc"], ["pydisasm"]],
|
|
||||||
[["pl", "pm", "t"], ["perl_syntax", "perldoc"]],
|
[["pl", "pm", "t"], ["perl_syntax", "perldoc"]],
|
||||||
[["p6", "pm6"], ["perl6_syntax"]],
|
[["p6", "pm6"], ["perl6_syntax"]],
|
||||||
[["pod", "pod6"], ["perldoc"]],
|
[["pod", "pod6"], ["perldoc"]],
|
||||||
|
|
@ -460,8 +460,13 @@ def make_tool_function(dependencies, command, url=None, error_status=None,
|
||||||
|
|
||||||
|
|
||||||
elinks, git_diff, git_blame = None, None, None # For linters.
|
elinks, git_diff, git_blame = None, None, None # For linters.
|
||||||
with importlib.resources.open_text(eris, "tools.toml") as tools_toml_file:
|
|
||||||
tools_toml = toml.load(tools_toml_file)
|
|
||||||
|
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)
|
||||||
tools_for_extensions = tools_toml["tools_for_extensions"]
|
tools_for_extensions = tools_toml["tools_for_extensions"]
|
||||||
del tools_toml["tools_for_extensions"]
|
del tools_toml["tools_for_extensions"]
|
||||||
for tool_name, tool_toml in tools_toml.items():
|
for tool_name, tool_toml in tools_toml.items():
|
||||||
|
|
@ -723,7 +728,7 @@ def tool_name_colored(tool, path):
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Let tools be tested individually...
|
# Let tools be tested individually...
|
||||||
# ./tools.py <tool> <path>
|
# ./tools.py <tool> <path>
|
||||||
# e.g. ./tools.py contents tools.toml
|
# e.g. ./tools.py contents README.md
|
||||||
tool_name, path = sys.argv[1:3]
|
tool_name, path = sys.argv[1:3]
|
||||||
tool = locals()[tool_name]
|
tool = locals()[tool_name]
|
||||||
valid_tools = tools_for_path(path)
|
valid_tools = tools_for_path(path)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ setup(name="eris",
|
||||||
license="Artistic 2.0",
|
license="Artistic 2.0",
|
||||||
packages=["eris"],
|
packages=["eris"],
|
||||||
py_modules=["lscolors", "sorted_collection"],
|
py_modules=["lscolors", "sorted_collection"],
|
||||||
package_data={"eris": ["LS_COLORS.sh", "tools.toml"]},
|
package_data={"eris": ["LS_COLORS.sh", "eris-tools.toml"]},
|
||||||
entry_points={"console_scripts": ["eris=eris.__main__:entry_point",
|
entry_points={"console_scripts": ["eris=eris.__main__:entry_point",
|
||||||
"eris-worker=eris.worker:main",
|
"eris-worker=eris.worker:main",
|
||||||
"eris-webserver=eris.webserver:main",
|
"eris-webserver=eris.webserver:main",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue