1 """
2 Application-class that implements pyFoamDumpRunDatabaseToCSV.py
3 """
4 from optparse import OptionGroup
5
6 from .PyFoamApplication import PyFoamApplication
7 from PyFoam.Basics.RunDatabase import RunDatabase
8
11 description="""\
12 Dump the contents of a SQLite database that holds run information to
13 a CSV-file
14 """
15 PyFoamApplication.__init__(self,
16 args=args,
17 description=description,
18 usage="%prog <database.db> <dump.csv>",
19 interspersed=True,
20 changeVersion=False,
21 nr=2,
22 exactNr=True)
23
25 how=OptionGroup(self.parser,
26 "Behavior",
27 "How the application should behave")
28 self.parser.add_option_group(how)
29
30 how.add_option("--verbose",
31 action="store_true",
32 dest="verbose",
33 default=False,
34 help="Tell about the data dumped")
35
36 what=OptionGroup(self.parser,
37 "What",
38 "Which information should be dumped")
39 self.parser.add_option_group(what)
40
41 what.add_option("--selection",
42 action="append",
43 dest="selection",
44 default=[],
45 help="""Regular expression (more than one can be
46 specified) to select data with (all the basic
47 run-data will be dumped anyway)""")
48
49
50
52 source=self.parser.getArgs()[0]
53 dest=self.parser.getArgs()[1]
54
55 db=RunDatabase(source,
56 verbose=self.opts.verbose)
57
58 selections=[]
59 if self.opts.selection:
60 selections=self.opts.selection
61
62 db.dumpToCSV(dest,selection=selections)
63
64
65