Hide keyboard shortcuts

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/>. 

21 

22from ..core.utils import iterable 

23 

24 

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. 

28 

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"). 

31 

32 Parameters 

33 ---------- 

34 context : click.Context 

35 

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. 

39 

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 

50 

51 

52def to_upper(context, param, value): 

53 """Convert a value to upper case. 

54 

55 Parameters 

56 ---------- 

57 context : click.Context 

58 

59 values : string 

60 The value to be converted. 

61 

62 Returns 

63 ------- 

64 string 

65 A copy of the passed-in value, converted to upper case. 

66 """ 

67 return value.upper()