From 915eac35ba428c64351e2b18c4730a85e6098bbd Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Thu, 17 May 2018 16:16:21 +1000 Subject: [PATCH] tools: Changed to toml instead of yaml. - toml is simpler than yaml and popular enough. --- install-dependencies | 2 +- setup.py | 2 +- vigil/tools.py | 12 ++--- vigil/tools.toml | 101 +++++++++++++++++++++++++++++++++++++++++++ vigil/tools.yaml | 101 ------------------------------------------- 5 files changed, 109 insertions(+), 109 deletions(-) create mode 100644 vigil/tools.toml delete mode 100644 vigil/tools.yaml diff --git a/install-dependencies b/install-dependencies index f9e1537..ba9ea7c 100755 --- a/install-dependencies +++ b/install-dependencies @@ -14,7 +14,7 @@ if [ $DIST_ID != "ubuntu" ]; then fi echo "Installing the dependencies of the vigil script..." sudo apt --yes install python3-pyinotify python3-pygments python3-docopt \ - python3-pillow util-linux python3-yaml + python3-pillow util-linux python3-toml echo echo "Installing all the tools vigil may need..." ./install-tools diff --git a/setup.py b/setup.py index 1dfa576..0f8c71c 100755 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ setup(name="vigil", author="Andrew Hamilton", license="Artistic 2.0", packages=["vigil", "vigil.urwid"], - package_data={"vigil": ["LS_COLORS.sh", "tools.yaml"]}, + package_data={"vigil": ["LS_COLORS.sh", "tools.toml"]}, entry_points={"console_scripts": ["vigil=vigil.__main__:entry_point", "vigil-worker=vigil.worker:main", diff --git a/vigil/tools.py b/vigil/tools.py index 9596844..cdc58bc 100644 --- a/vigil/tools.py +++ b/vigil/tools.py @@ -25,7 +25,7 @@ import PIL.Image import pygments import pygments.lexers import pygments.styles -import yaml +import toml import vigil.fill3 as fill3 import vigil.gut as gut @@ -645,11 +645,11 @@ def make_tool_function(dependencies, url, command, success_status=None, return func -tools_yaml_path = os.path.join(os.path.dirname(__file__), "tools.yaml") -with open(tools_yaml_path) as tools_yaml_file: - tools_yaml = yaml.load(tools_yaml_file.read()) -for tool_name, tool_yaml in tools_yaml.items(): - tool_func = make_tool_function(**tool_yaml) +tools_toml_path = os.path.join(os.path.dirname(__file__), "tools.toml") +with open(tools_toml_path) as tools_toml_file: + tools_toml = toml.load(tools_toml_file) +for tool_name, tool_toml in tools_toml.items(): + tool_func = make_tool_function(**tool_toml) tool_func.__name__ = tool_func.__qualname__ = tool_name globals()[tool_name] = tool_func diff --git a/vigil/tools.toml b/vigil/tools.toml new file mode 100644 index 0000000..6016d56 --- /dev/null +++ b/vigil/tools.toml @@ -0,0 +1,101 @@ + + +# Template: +# [] +# dependencies = [""] +# url = "" +# command = "" +# success_status = "" +# error_status = "" + + +[objdump_headers] + dependencies = ["binutils"] + url = "https://en.wikipedia.org/wiki/Objdump" + command = "objdump --all-headers" + success_status = "normal" + +[objdump_disassemble] + dependencies = ["binutils"] + url = "https://en.wikipedia.org/wiki/Objdump" + command = "objdump --disassemble --reloc --dynamic-reloc" + success_status = "normal" + +[readelf] + dependencies = ["binutils"] + url = "https://en.wikipedia.org/wiki/Objdump" + command = "readelf --all" + success_status = "normal" + +[unzip] + dependencies = ["unzip"] + url = "unzip" + command = "unzip -l" + success_status = "normal" + +[tar_gz] + dependencies = ["tar"] + url = "http://www.gnu.org/software/tar/manual/tar.html" + command = "tar ztvf" + success_status = "normal" + +[tar_bz2] + dependencies = ["tar"] + url = "http://www.gnu.org/software/tar/manual/tar.html" + command = "tar jtvf" + success_status = "normal" + +[nm] + dependencies = ["binutils"] + url = "https://linux.die.net/man/1/nm" + command = "nm --demangle" + success_status = "normal" + +[pdf2txt] + dependencies = ["python-pdfminer"] + url = "python-pdfminer" + command = "pdf2txt" + success_status = "normal" + +[html2text] + dependencies = ["html2text"] + url = "html2text" + command = "html2text" + success_status = "normal" + +[c_syntax_gcc] + dependencies = ["gcc", "g++-6"] + url = "https://gcc.gnu.org/" + command = "gcc -fsyntax-only" + +[cpp_syntax_gcc] + dependencies = ["gcc", "g++-6"] + url = "https://gcc.gnu.org/" + command = "gcc -fsyntax-only" + +[php7_syntax] + dependencies = ["php7.2-cli"] + url = "https://en.wikipedia.org/wiki/PHP" + command = "php7.2 --syntax-check" + +[shellcheck] + dependencies = ["shellcheck"] + url = "shellcheck" + command = "shellcheck" + +[cppcheck] + dependencies = ["cppcheck"] + url = "cppcheck" + command = "cppcheck" + +[gofmt] + dependencies = ["golang-go"] + url = "golang-go" + command = "gofmt" + success_status = "normal" + +[go_vet] + dependencies = ["golang-go"] + url = "golang-go" + command = "go vet" + error_status = "normal" diff --git a/vigil/tools.yaml b/vigil/tools.yaml deleted file mode 100644 index 67939e6..0000000 --- a/vigil/tools.yaml +++ /dev/null @@ -1,101 +0,0 @@ - - -# Template: -# : -# dependencies: [] -# url: -# command: -# success_status: -# error_status: - - -objdump_headers: - dependencies: [binutils] - url: https://en.wikipedia.org/wiki/Objdump - command: objdump --all-headers - success_status: normal - -objdump_disassemble: - dependencies: [binutils] - url: https://en.wikipedia.org/wiki/Objdump - command: objdump --disassemble --reloc --dynamic-reloc - success_status: normal - -readelf: - dependencies: [binutils] - url: https://en.wikipedia.org/wiki/Objdump - command: readelf --all - success_status: normal - -unzip: - dependencies: [unzip] - url: unzip - command: unzip -l - success_status: normal - -tar_gz: - dependencies: [tar] - url: http://www.gnu.org/software/tar/manual/tar.html - command: tar ztvf - success_status: normal - -tar_bz2: - dependencies: [tar] - url: http://www.gnu.org/software/tar/manual/tar.html - command: tar jtvf - success_status: normal - -nm: - dependencies: [binutils] - url: https://linux.die.net/man/1/nm - command: nm --demangle - success_status: normal - -pdf2txt: - dependencies: [python-pdfminer] - url: python-pdfminer - command: pdf2txt - success_status: normal - -html2text: - dependencies: [html2text] - url: html2text - command: html2text - success_status: normal - -c_syntax_gcc: - dependencies: [gcc, g++-6] - url: https://gcc.gnu.org/ - command: gcc -fsyntax-only - -cpp_syntax_gcc: - dependencies: [gcc, g++-6] - url: https://gcc.gnu.org/ - command: gcc -fsyntax-only - -php7_syntax: - dependencies: [php7.2-cli] - url: https://en.wikipedia.org/wiki/PHP - command: php7.2 --syntax-check - -shellcheck: - dependencies: [shellcheck] - url: shellcheck - command: shellcheck - -cppcheck: - dependencies: [cppcheck] - url: cppcheck - command: cppcheck - -gofmt: - dependencies: [golang-go] - url: golang-go - command: gofmt - success_status: normal - -go_vet: - dependencies: [golang-go] - url: golang-go - command: go vet - error_status: normal