12 from typing
import Optional, Iterable, List
17 Class to simplify the parsing of plot options
18 supplied by the MetaOption named object attached
21 A typical meta options list might look like this:
22 ["pvalue-warn=0.9", "pvalue-error=0.4"]
25 def __init__(self, meta_option_list: Optional[Iterable] =
None):
27 Initialize MetaOptionParser
28 @param meta_option_list: list of meta options read from ROOT object
31 if meta_option_list
is None:
33 meta_option_list = list(meta_option_list)
35 self.mo: List[str] = meta_option_list
39 Checks whether an option is contained in the
41 @param option_name: name of the option to check for
42 @return: True if the option is contained in the meta option list
45 return option_name
in self.mo
49 @return: The custom warning level for the pvalue setting of plot
50 comparison. None if no custom value was set for the plot.
56 @return: The custom error level for the pvalue setting of plot
57 comparison. None if no custom value was set for the plot.
61 def float_value(self, key, default: Optional[float] =
None) -> float:
63 Extract the float value from a meta option list
64 @param key: the key to identify the value from the list
65 @param default: default value
66 @return: The float value or the default value if this key did not exist
67 or the float value could not be parsed.
77 def int_value(self, key, default: Optional[int] =
None) -> int:
79 Extract the int value from a meta option list
80 @param key: the key to identify the value from the list
81 @param default: default value
82 @return: The int value or None if this key did not exist
83 or the float value could not be parsed.
95 Searches the meta options list for a key value entry and parses it
96 @param key: The key to look for
97 @retun: The value which was associated to the key or None if the
100 it = [s
for s
in self.mo
if s.startswith(key +
"=")]
104 key_value_pair = it[0].split(
"=")
106 if len(key_value_pair) < 2:
109 return key_value_pair[1]