From 9ce7c5ffb95ddd54b6422e9ff50dd8b5ae207f58 Mon Sep 17 00:00:00 2001 From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de> Date: Sat, 23 Jan 2016 23:22:05 +0100 Subject: [PATCH] expand executable script a choice between the basic classes can now be made. anything but NavierStokes will fail miserably at the moment though... --- bfps/Launcher.py | 30 ++++++++++++++++++++++++++++-- bfps/__main__.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/bfps/Launcher.py b/bfps/Launcher.py index fefa2978..d35cf42b 100644 --- a/bfps/Launcher.py +++ b/bfps/Launcher.py @@ -1,8 +1,34 @@ +####################################################################### +# # +# Copyright 2015 Max Planck Institute # +# for Dynamics and Self-Organization # +# # +# This file is part of bfps. # +# # +# bfps 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. # +# # +# bfps 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 bfps. If not, see <http://www.gnu.org/licenses/> # +# # +# Contact: Cristian.Lalescu@ds.mpg.de # +# # +####################################################################### + + + import os import argparse -import .__init__ as bfps +import bfps from .NavierStokes import NavierStokes from .FluidResize import FluidResize from .FluidConvert import FluidConvert @@ -12,7 +38,7 @@ class Launcher: self, base_class = NavierStokes): self.base_class = base_class - self.parser = argparse.ArgumentParser(prog = 'bfps') + self.parser = argparse.ArgumentParser(prog = 'bfps ' + self.base_class.__name__) self.parser.add_argument( '-v', '--version', action = 'version', diff --git a/bfps/__main__.py b/bfps/__main__.py index 74703976..75e511f7 100644 --- a/bfps/__main__.py +++ b/bfps/__main__.py @@ -1,9 +1,53 @@ +####################################################################### +# # +# Copyright 2015 Max Planck Institute # +# for Dynamics and Self-Organization # +# # +# This file is part of bfps. # +# # +# bfps 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. # +# # +# bfps 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 bfps. If not, see <http://www.gnu.org/licenses/> # +# # +# Contact: Cristian.Lalescu@ds.mpg.de # +# # +####################################################################### + + + import sys +import argparse + +import bfps from .Launcher import Launcher +from .NavierStokes import NavierStokes +from .FluidConvert import FluidConvert +from .FluidResize import FluidResize def main(): - l = Launcher() - l(sys.argv[1:]) + parser = argparse.ArgumentParser(prog = 'bfps') + parser.add_argument( + '-v', '--version', + action = 'version', + version = '%(prog)s ' + bfps.__version__) + parser.add_argument( + 'base_class', + choices = ['NavierStokes', + 'FluidConvert', + 'FluidResize'], + type = str) + opt = parser.parse_args(sys.argv[1:2]) + l = eval('Launcher(base_class = {0})'.format(opt.base_class)) + l(sys.argv[2:]) return None if __name__ == '__main__': -- GitLab