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_option
25from .opt import (delete_option,
26 task_option)
27from ..cmdLineParser import (_ACTION_ADD_TASK,
28 _ACTION_DELETE_TASK,
29 _ACTION_CONFIG,
30 _ACTION_CONFIG_FILE,
31 _ACTION_ADD_INSTRUMENT)
34def makePipelineActions(args,
35 taskFlags=task_option.opts(),
36 deleteFlags=delete_option.opts(),
37 configFlags=config_option.opts(),
38 configFileFlags=config_file_option.opts(),
39 instrumentFlags=instrument_option.opts()):
40 """Make a list of pipline actions from a list of option flags and
41 values.
43 Parameters
44 ----------
45 args : `list` [`str`]
46 The arguments, option flags, and option values in the order they were
47 passed in on the command line.
48 taskFlags : `list` [`str`], optional
49 The option flags to use to recoginze a task action, by default
50 task_option.opts()
51 deleteFlags : `list` [`str`], optional
52 The option flags to use to recoginze a delete action, by default
53 delete_option.opts()
54 configFlags : `list` [`str`], optional
55 The option flags to use to recoginze a config action, by default
56 config_option.opts()
57 configFileFlags : `list` [`str`], optional
58 The option flags to use to recoginze a config-file action, by default
59 config_file_option.opts()
60 instrumentFlags : `list` [`str`], optional
61 The option flags to use to recoginze an instrument action, by default
62 instrument_option.opts()
64 Returns
65 -------
66 pipelineActions : `list` [`_PipelineActionType`]
67 A list of pipeline actions constructed form their arguments in args,
68 in the order they appeared in args.
69 """
70 pipelineActions = []
71 # iterate up to the second-to-last element, if the second to last element
72 # is a key we're looking for, the last item will be its value.
73 for i in range(len(args)-1):
74 if args[i] in taskFlags:
75 pipelineActions.append(_ACTION_ADD_TASK(args[i+1]))
76 elif args[i] in deleteFlags:
77 pipelineActions.append(_ACTION_DELETE_TASK(args[i+1]))
78 elif args[i] in configFlags:
79 pipelineActions.append(_ACTION_CONFIG(args[i+1]))
80 elif args[i] in configFileFlags:
81 pipelineActions.append(_ACTION_CONFIG_FILE(args[i+1]))
82 elif args[i] in instrumentFlags:
83 pipelineActions.append(_ACTION_ADD_INSTRUMENT(args[i+1]))
84 return pipelineActions