O2-DQ User Interface 1.0.0
Loading...
Searching...
No Matches
helperOptions.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
16import argparse
17
18from extramodules.choicesCompleterList import ChoicesCompleterList
19from argcomplete.completers import ChoicesCompleter
20
21
22class HelperOptions(object):
23
24 """
25 Class for Interface -> Helper Options
26
27 Args:
28 object (parser_args() object): Helper Options Interface
29 """
30
31 def __init__(self, parserHelperOptions = argparse.ArgumentParser(add_help = False)):
32 super(HelperOptions, self).__init__()
33 self.parserHelperOptions = parserHelperOptions
34
35 def addArguments(self):
36 """
37 This function allows to add arguments for parser_args() function
38 """
39
40 # Predefined Selections
41 debugLevelSelections = {
42 "NOTSET": "Set Debug Level to NOTSET",
43 "DEBUG": "Set Debug Level to DEBUG",
44 "INFO": "Set Debug Level to INFO",
45 "WARNING": "Set Debug Level to WARNING",
46 "ERROR": "Set Debug Level to ERROR",
47 "CRITICAL": "Set Debug Level to CRITICAL",
48 }
49 debugLevelSelectionsList = []
50 for k, v in debugLevelSelections.items():
51 debugLevelSelectionsList.append(k)
52
53 booleanSelections = ["true", "false"]
54
55 # Interface
56 groupDebugOptions = self.parserHelperOptions.add_argument_group(title = "Additional Debug Options")
57 groupDebugOptions.add_argument(
58 "--debug", help = "execute with debug options", action = "store", type = str.upper, default = "INFO",
59 choices = debugLevelSelectionsList,
60 ).completer = ChoicesCompleterList(debugLevelSelectionsList)
61 groupDebugOptions.add_argument("--logFile", help = "Enable logger for both file and CLI", action = "store_true")
62 groupDebug = self.parserHelperOptions.add_argument_group(title = "Choice List for debug Parameters")
63
64 for key, value in debugLevelSelections.items():
65 groupDebug.add_argument(key, help = value, action = "none")
66
67 groupAutomations = self.parserHelperOptions.add_argument_group(title = "Automation Parameters")
68 groupAutomations.add_argument(
69 "--onlySelect", help = "If false JSON Overrider Interface If true JSON Additional Interface", action = "store",
70 default = "true", type = str.lower, choices = booleanSelections,
71 ).completer = ChoicesCompleter(booleanSelections)
72 groupAutomations.add_argument(
73 "--autoDummy", help = "Dummy automize parameter (don't configure it, true is highly recomended for automation)",
74 action = "store", default = "true", type = str.lower, choices = booleanSelections,
75 ).completer = ChoicesCompleter(booleanSelections)
76
77 def parseArgs(self):
78 """
79 This function allows to save the obtained arguments to the parser_args() function
80
81 Returns:
82 Namespace: returns parse_args()
83 """
84
85 return self.parserHelperOptions.parse_args()
def __init__(self, parserHelperOptions=argparse.ArgumentParser(add_help=False))