5 from typing
import Optional, Iterable, List
10 Class to simplify the parsing of plot options
11 supplied by the MetaOption named object attached
14 A typical meta options list might look like this:
15 ["pvalue-warn=0.9", "pvalue-error=0.4"]
18 def __init__(self, meta_option_list: Optional[Iterable] =
None):
20 Initialize MetaOptionParser
21 @param meta_option_list: list of meta options read from ROOT object
24 if meta_option_list
is None:
26 meta_option_list = list(meta_option_list)
28 self.
mo = meta_option_list
32 Checks whether an option is contained in the
34 @param option_name: name of the option to check for
35 @return: True if the option is contained in the meta option list
38 return option_name
in self.
mo
42 @return: The custom warning level for the pvalue setting of plot
43 comparison. None if no custom value was set for the plot.
49 @return: The custom error level for the pvalue setting of plot
50 comparison. None if no custom value was set for the plot.
56 Extract the float value from a meta option list
57 @param key: the key to identify the value from the list
58 @param default: default value
59 @return: The float value or the default value if this key did not exist
60 or the float value could not be parsed.
72 Extract the int value from a meta option list
73 @param key: the key to identify the value from the list
74 @param default: default value
75 @return: The int value or None if this key did not exist
76 or the float value could not be parsed.
88 Searches the meta options list for a key value entry and parses it
89 @param key: The key to look for
90 @retun: The value which was associated to the key or None if the
93 it = [s
for s
in self.
mo if s.startswith(key +
"=")]
97 key_value_pair = it[0].split(
"=")
99 if len(key_value_pair) < 2:
102 return key_value_pair[1]