Coding style
- Extract function since check_arguments in too long.
This commit is contained in:
parent
2dcae9fbf8
commit
29c359d39d
1 changed files with 25 additions and 22 deletions
|
|
@ -1125,6 +1125,30 @@ def print_tool_info():
|
|||
print()
|
||||
|
||||
|
||||
def install_all_tools():
|
||||
tools_ = tools.dependencies()
|
||||
os_release_lines = open("/etc/os-release").readlines()
|
||||
install_command = ["apt", "-y", "install"] # debian / ubuntu
|
||||
if "ID=fedora\n" in os_release_lines:
|
||||
tools_.remove("lua-check")
|
||||
renames = {"lua5.3": "lua", "python3-bandit": "bandit", "ruby3.1": "ruby",
|
||||
"xz-utils": "xz"}
|
||||
tools_ = [renames.get(tool, tool) for tool in tools_]
|
||||
install_command = ["dnf", "-y", "install"]
|
||||
elif "ID=arch\n" in os_release_lines:
|
||||
tools_.remove("rakudo")
|
||||
tools_.remove("python3-pdfminer") # pdf2txt is not in arch
|
||||
tools_.remove("perl-doc") # perldoc is in perl but not in the path
|
||||
renames = {"genisoimage": "cdrkit", "lua5.3": "lua", "ruby3.1": "ruby", "xz-utils": "xz",
|
||||
"g++": "gcc", "golang-go": "go", "lua-check": "luacheck", "php-cli": "php",
|
||||
"pylint": "python-pylint", "python3-bandit": "bandit", "python3-mypy": "mypy"}
|
||||
tools_ = [renames.get(tool, tool) for tool in tools_]
|
||||
tools_ = ["python-" + tool[len("python3-"):] if tool.startswith("python3-") else tool
|
||||
for tool in tools_]
|
||||
install_command = ["pacman", "--noconfirm", "-S"]
|
||||
subprocess.run(["sudo"] + install_command + sorted(tools_), check=True)
|
||||
|
||||
|
||||
def check_arguments():
|
||||
global tools
|
||||
cmdline_help = __doc__ + USAGE.replace("*", "")
|
||||
|
|
@ -1144,28 +1168,7 @@ def check_arguments():
|
|||
import eris.tools as tools
|
||||
if arguments["--install-all-tools"]:
|
||||
print("Installing all tools… (requires sudo)")
|
||||
tools_ = tools.dependencies()
|
||||
os_release_lines = open("/etc/os-release").readlines()
|
||||
if "ID=fedora\n" in os_release_lines:
|
||||
tools_.remove("lua-check")
|
||||
renames = {"lua5.3": "lua", "python3-bandit": "bandit",
|
||||
"ruby3.1": "ruby", "xz-utils": "xz"}
|
||||
tools_ = [renames.get(tool, tool) for tool in tools_]
|
||||
subprocess.run(["sudo", "dnf", "-y", "install"] + sorted(tools_), check=True)
|
||||
elif "ID=arch\n" in os_release_lines:
|
||||
tools_.remove("rakudo")
|
||||
tools_.remove("python3-pdfminer") # pdf2txt is not in arch
|
||||
tools_.remove("perl-doc") # perldoc is in perl but not in the path
|
||||
renames = {"genisoimage": "cdrkit", "lua5.3": "lua", "ruby3.1": "ruby",
|
||||
"xz-utils": "xz", "g++": "gcc", "golang-go": "go", "lua-check": "luacheck",
|
||||
"php-cli": "php", "pylint": "python-pylint", "python3-bandit": "bandit",
|
||||
"python3-mypy": "mypy"}
|
||||
tools_ = [renames.get(tool, tool) for tool in tools_]
|
||||
tools_ = ["python-" + tool[len("python3-"):] if tool.startswith("python3-") else tool
|
||||
for tool in tools_]
|
||||
subprocess.run(["sudo", "pacman", "--noconfirm", "-S"] + sorted(tools_), check=True)
|
||||
else: # debian / ubuntu
|
||||
subprocess.run(["sudo", "apt", "-y", "install"] + sorted(tools_), check=True)
|
||||
install_all_tools()
|
||||
print("Done.")
|
||||
sys.exit(0)
|
||||
if arguments["--info"]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue