101def _decode_pmon_opts(opts, dry_run=False):
102 """helper function to decode athena-command-line options.
103
104 @param opts is a list of options which can enable or disable a few
105 jobproperties.PerfMonFlags fields
106
107 @param dry_run to only decode but not set the options
108
109 one activates a perfmon flag by prepending '+' in front of the option name
110 (or nothing prepended, '+' being the implied default)
111 and de-activates it by prepending '-'.
112 """
113 pmf = jobproperties.PerfMonFlags
114 dispatch = {
115 'perfmonmt': pmf.doMonitoringMT,
116 'fastmonmt': pmf.doFastMonMT,
117 'fullmonmt': pmf.doFullMonMT,
118 }
119
120 for opt in opts:
121 flag_name = opt[:]
122 val = True
123 if opt.startswith('-'):
124 val = False
125 flag_name = flag_name[1:]
126 elif opt.startswith('+'):
127 val = True
128 flag_name = flag_name[1:]
129 if flag_name not in dispatch:
130 raise ValueError(
131 '[%s] is not a valid PerfMonFlag (allowed: %r)' %
132 (flag_name, list(dispatch.keys()))
133 )
134
135 if not dry_run:
136 dispatch[flag_name].set_Value(val)