O2-DQ User Interface 1.0.0
Loading...
Searching...
No Matches
configSetter.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# PYTHON_ARGCOMPLETE_OK
3# -*- coding: utf-8 -*-
4
5# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
6# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
7# All rights not expressly granted are reserved.
8#
9# This software is distributed under the terms of the GNU General Public
10# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
11#
12# In applying this license CERN does not waive the privileges and immunities
13# granted to it by virtue of its status as an Intergovernmental Organization
14# or submit itself to any jurisdiction.
15
16# This script includes setter functions for configurables
17
18#from extramodules.dqOperations import listToString
19from .stringOperations import listToString
20
21
22# We don't need this. config[key][value] = args.<arg> has less verbosity
23def singleConfigurableSet(config: dict, key: str, value: str, arg: str):
24 """
25 singleConfigurableSet method allows to assign value
26 to single configurable value arguments in JSON with overriding.
27 This method is used for single value arguments
28 as JSONs will be assigned only by overriding for single value arguments.
29
30
31 Args:
32 config (dict): Input as JSON config file
33 key (string): Sub key from upper key in provided JSON config file
34 value (string): Value from key in provided JSON config file (sub-level)
35 arg (any): Argument from parserargs or manual for some situations ("-1" or "true" or "false" etc.)
36
37
38 Assignment:
39 string: Assigned as a direct string
40
41 """
42
43 config[key][value] = arg
44 #logging.debug(" - [%s] %s : %s", key, value, args.v0Rmax)
45
46
47# For multiple configurables in JSON, always use this method for less verbosity
48def multiConfigurableSet(config: dict, key: str, value: str, arg: list, onlySelect):
49 """
50 multiConfigurableSet method allows to assign values
51 for multiple configurable value arguments in JSON with/without overriding
52 depending on interface mode. The onlySelect parameter decides for
53 interface mode.if the argument contains more than one value, it is saved as list type by default
54 and this method converts them to comma separated string, otherwise assigns them as string value directly
55
56
57 Args:
58 config (dict): Input as JSON config file
59 key (string): Sub key from upper key in provided config JSON config file
60 value (string): Value from key in provided JSON config file (sub-level)
61 arg (any): Argument from parserargs
62 onlySelect (boolean): Input as args.onlySelect for selecting interface mode.
63 true for Overrider Mode and false for Additional mode
64
65
66 Assignment :
67 string or comma seperated string: If the argument is of list type,
68 it assign as a comma separated string,
69 otherwise it assign directly as a string.
70
71 """
72
73 if isinstance(arg, list):
74 arg = listToString(arg)
75 if onlySelect == "false":
76 actualConfig = config[key][value]
77 arg = actualConfig + "," + arg
78 config[key][value] = arg
79
80
81# TODO: refactor it it should be work in also loop. Only works for tableReader and dqEfficiency
82# when key have no process Dummy function, this method will crashes.
83def processDummySet(config: dict):
84
85 for k, v in config.items(): # loop over number of keys
86 if isinstance(v, dict): # iterate only possible items in dict keys
87 for v, v2 in v.items():
88 if (not v.endswith("Dummy")) and (v.startswith("process")):
89 if config[k][v] == "true":
90 config[k]["processDummy"] = "false"
91 print(k, "dummy converted false")
92 break
93 else:
94 config[k]["processDummy"] = "true"
95 print(k, "dummy converted true")
def singleConfigurableSet(dict config, str key, str value, str arg)
Definition: configSetter.py:23