Coverage for python/lsst/ctrl/mpexec/cli/utils.py : 17%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of ctrl_mpexec.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
23from lsst.daf.butler.cli.opt import (config_file_option, config_option)
24from lsst.obs.base.cli.opt import instrument_parameter
25from .opt import (delete_option, task_option)
26from ..cmdLineParser import (_ACTION_ADD_TASK,
27 _ACTION_DELETE_TASK,
28 _ACTION_CONFIG,
29 _ACTION_CONFIG_FILE,
30 _ACTION_ADD_INSTRUMENT)
33def makePipelineActions(args,
34 taskFlags=task_option.optionFlags,
35 deleteFlags=delete_option.optionFlags,
36 configFlags=config_option.optionFlags,
37 configFileFlags=config_file_option.optionFlags,
38 instrumentFlags=instrument_parameter.optionFlags):
39 """Make a list of pipline actions from a list of option flags and
40 values.
42 Parameters
43 ----------
44 args : `list` [`str`]
45 The arguments, option flags, and option values in the order they were
46 passed in on the command line.
47 taskFlags : `list` [`str`], optional
48 The option flags to use to recoginze a task action, by default
49 task_option.optionFlags
50 deleteFlags : `list` [`str`], optional
51 The option flags to use to recoginze a delete action, by default
52 delete_option.optionFlags
53 configFlags : `list` [`str`], optional
54 The option flags to use to recoginze a config action, by default
55 config_option.optionFlags
56 configFileFlags : `list` [`str`], optional
57 The option flags to use to recoginze a config-file action, by default
58 config_file_option.optionFlags
59 instrumentFlags : `list` [`str`], optional
60 The option flags to use to recoginze an instrument action, by default
61 instrument_parameter.optionFlags
63 Returns
64 -------
65 pipelineActions : `list` [`_PipelineActionType`]
66 A list of pipeline actions constructed form their arguments in args,
67 in the order they appeared in args.
68 """
69 pipelineActions = []
70 # iterate up to the second-to-last element, if the second to last element
71 # is a key we're looking for, the last item will be its value.
72 for i in range(len(args)-1):
73 if args[i] in taskFlags:
74 pipelineActions.append(_ACTION_ADD_TASK(args[i+1]))
75 elif args[i] in deleteFlags:
76 pipelineActions.append(_ACTION_DELETE_TASK(args[i+1]))
77 elif args[i] in configFlags:
78 pipelineActions.append(_ACTION_CONFIG(args[i+1]))
79 elif args[i] in configFileFlags:
80 pipelineActions.append(_ACTION_CONFIG_FILE(args[i+1]))
81 elif args[i] in instrumentFlags:
82 pipelineActions.append(_ACTION_ADD_INSTRUMENT(args[i+1]))
83 return pipelineActions