16
16
import cwa
17
17
import os
18
18
import sys
19
- import timeit
19
+ import time
20
20
21
21
def get (config , section , key ):
22
22
if key in config [section ]:
23
23
return config [section ][key ]
24
24
return None
25
25
26
+ def getb (config , section , key ):
27
+ """ Get boolean value from config file """
28
+ value = get (config , section , key )
29
+ if value is None :
30
+ return False
31
+ return bool (value )
32
+
26
33
def process (file , configFile ):
27
34
28
35
config = configparser .ConfigParser ()
@@ -71,41 +78,33 @@ def process(file, configFile):
71
78
"rms_total" ,
72
79
"std_dev_total" ]
73
80
74
- # Make sure that there are defaults
75
-
76
-
77
81
for thisPlot in plotType :
78
- plotMinutes = ax3_plot_minutes .PlotMinutes ()
79
-
80
- configSection = config [thisPlot ]
81
- # Defaults if not specified, even in DEFAULT section
82
+ if getb (config , thisPlot , "ax3_plot_minutes" ):
83
+ plotMinutes = ax3_plot_minutes .PlotMinutes ()
82
84
83
- bcontrolfile = get (config , thisPlot , "bcontrolfile" )
84
- nbcontrolfile = get (config , thisPlot , "nbcontrolfile" )
85
+ bcontrolfile = get (config , thisPlot , "bcontrolfile" )
86
+ nbcontrolfile = get (config , thisPlot , "nbcontrolfile" )
85
87
86
- showtime = get (config , thisPlot , "showtime" )
87
- if showtime is not None :
88
- showtime = bool (showtime )
88
+ showtime = getb (config , thisPlot , "showtime" )
89
89
90
- grid = get (config , thisPlot , "grid" )
91
- if grid is not None :
92
- grid = bool (grid )
90
+ grid = getb (config , thisPlot , "grid" )
93
91
94
- ymin = get (config , thisPlot , "ymin" )
95
- if ymin is not None :
92
+ ymin = get (config , thisPlot , "ymin" )
93
+ if ymin is not None :
96
94
ymin = float (ymin )
97
95
98
- ymax = get (config , thisPlot , "ymax" )
99
- if ymax is not None :
100
- ymax = float (ymax )
96
+ ymax = get (config , thisPlot , "ymax" )
97
+ if ymax is not None :
98
+ ymax = float (ymax )
101
99
102
- text = get ( config , thisPlot , "text" )
103
- # Only one config file for the baselined and nonbaselined files at the moment
104
- plotMinutes (nonBaselinedFile , nbcontrolfile ,
105
- showtime , ymin , ymax , thisPlot , grid )
106
- plotMinutes (baselinedFile , bcontrolfile ,
107
- showtime , ymin , ymax , thisPlot , grid )
100
+ # Only one config file for the baselined and nonbaselined
101
+ # files at the moment
102
+ plotMinutes (nonBaselinedFile , nbcontrolfile ,
103
+ showtime , ymin , ymax , thisPlot , grid )
104
+ plotMinutes (baselinedFile , bcontrolfile ,
105
+ showtime , ymin , ymax , thisPlot , grid )
108
106
107
+ if getb (config , thisPlot , "ax3_seconds_stat" ):
109
108
limit = get (config , "seconds_stat" , "limit" )
110
109
if limit is not None :
111
110
limit = float (limit )
@@ -129,7 +128,9 @@ def main():
129
128
print ("You need the .CWA, not the .csv" , file = stderr )
130
129
os .exit (0 )
131
130
132
- elapsed = timeit .timeit (process (filePath , controlFile ))
131
+ elapsed = time .time ();
132
+ process (filePath , controlFile )
133
+ elapsed = time .time () - elapsed
133
134
print (f"Elapsed tile { elapsed } " )
134
135
135
136
if __name__ == "__main__" :
0 commit comments