Coverage for python/lsst/daf/butler/cli/utils.py : 30%

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 daf_butler.
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/>.
22from ..core.utils import iterable
25def split_commas(context, param, values):
26 """Process a tuple of values, where each value may contain comma-separated
27 values, and return a single list of all the passed-in values.
29 This function can be passed to the 'callback' argument of a click.option to
30 allow it to process comma-separated values (e.g. "--my-opt a,b,c").
32 Parameters
33 ----------
34 context : click.Context
36 values : tuple of string
37 All the values passed for this option. Strings may contain commas,
38 which will be treated as delimiters for separate values.
40 Returns
41 -------
42 list of string
43 The passed in values separated by commas and combined into a single
44 list.
45 """
46 valueList = []
47 for value in iterable(values):
48 valueList.extend(value.split(","))
49 return valueList
52def to_upper(context, param, value):
53 """Convert a value to upper case.
55 Parameters
56 ----------
57 context : click.Context
59 values : string
60 The value to be converted.
62 Returns
63 -------
64 string
65 A copy of the passed-in value, converted to upper case.
66 """
67 return value.upper()