From e556bcff540f4a8d2deb8cb339044c0cb9b1c014 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 24 Oct 2023 15:13:35 +0200 Subject: [PATCH] Script: Add script command list solver. --- src/Scripts/ListSolver.py | 38 ++++++++++++++++++++++++++++++++++++++ src/pamhyr.py | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 src/Scripts/ListSolver.py diff --git a/src/Scripts/ListSolver.py b/src/Scripts/ListSolver.py new file mode 100644 index 00000000..fe50d8d9 --- /dev/null +++ b/src/Scripts/ListSolver.py @@ -0,0 +1,38 @@ +# ListSolver.py -- Pamhyr +# Copyright (C) 2023 INRAE +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# -*- coding: utf-8 -*- + +import os +import logging + +from Scripts.AScript import AScript + +logger = logging.getLogger() + + +class ScriptListSolver(AScript): + name = "ListSolver" + description = "List configured solver(s) for Pamhyr2" + + def usage(self): + logger.info(f"Usage : {self._args[0]} {self._args[1]}") + + def run(self): + for solver in self._conf.solvers: + print(f"{solver.name:<16} ({solver.type}): {solver.description}") + + return 0 diff --git a/src/pamhyr.py b/src/pamhyr.py index f2652686..5d274166 100755 --- a/src/pamhyr.py +++ b/src/pamhyr.py @@ -37,6 +37,7 @@ from Model.Study import Study from Scripts.P3DST import Script3DST from Scripts.Hello import ScriptHello +from Scripts.ListSolver import ScriptListSolver from Scripts.Run import ScriptExport, ScriptRun from init import legal_info, debug_info, setup_lang @@ -45,6 +46,7 @@ logger = logging.getLogger() scripts = { "hello": ScriptHello, + "solvers": ScriptListSolver, "export": ScriptExport, "run": ScriptRun, "3DST": Script3DST,