__main__.py 2.52 KB
Newer Older
Cristian Lalescu's avatar
Cristian Lalescu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#######################################################################
#                                                                     #
#  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                                 #
#                                                                     #
#######################################################################



Cristian Lalescu's avatar
Cristian Lalescu committed
27
import sys
Cristian Lalescu's avatar
Cristian Lalescu committed
28
29
30
31
32
33
import argparse

import bfps
from .NavierStokes import NavierStokes
from .FluidConvert import FluidConvert
from .FluidResize import FluidResize
Cristian Lalescu's avatar
Cristian Lalescu committed
34
35

def main():
Cristian Lalescu's avatar
Cristian Lalescu committed
36
37
38
39
40
41
42
43
44
45
    parser = argparse.ArgumentParser(prog = 'bfps')
    parser.add_argument(
            '-v', '--version',
            action = 'version',
            version = '%(prog)s ' + bfps.__version__)
    parser.add_argument(
            'base_class',
            choices = ['NavierStokes',
                       'FluidResize'],
            type = str)
46
    # first option is the choice of base class or -h or -v
47
    # all other options are passed on to the base_class instance
Cristian Lalescu's avatar
Cristian Lalescu committed
48
    opt = parser.parse_args(sys.argv[1:2])
49
50
    # error is thrown if first option is not a base class, so Launcher
    # cannot be executed by mistake.
51
    c = eval('{0}()'.format(opt.base_class))
Cristian Lalescu's avatar
Cristian Lalescu committed
52
    c.launch(args = sys.argv[2:])
Cristian Lalescu's avatar
Cristian Lalescu committed
53
54
55
56
57
    return None

if __name__ == '__main__':
    main()