1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 """C{select FUNCTION}
19
20 C{FUNCTION} is applied to input objects. Objects for which C{FUNCTION}
21 evaluates to true are sent to the output stream.
22
23 B{Example}: For the input C{(1,), (2,), (3,), (4,)}, this command::
24
25 select 'x: (x % 2) == 0'
26
27 generates the output C{(2,), (4,)}.
28 """
29
30 import osh.function
31 import osh.core
32
33
36
37
39 """Input objects for which C{function} evaluates to true are sent to the output stream.
40 """
41 return _Select().process_args(function)
42
44
45 _function = None
46
47
48
49
52
53
54
55
58
60 args = self.args()
61 self._function = args.next_function()
62 if self._function is None or args.has_next():
63 self.usage()
64
65
66
67
69
70 if self._function(*object):
71 self.send(object)
72