| Home | Trees | Indices | Help |
|
|---|
|
|
1 # osh
2 # Copyright (C) Jack Orenstein <jao@geophile.com>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 """C{py PYTHON_CODE}
19
20 C{PYTHON_CODE} is executed, and any variables defined are available to
21 subsequent commands in the same command line.
22
23 B{Example}::
24
25 osh py 'a = 123; b = 456' ^ f '(a, b)' $
26
27 This command generates the output C{'(123, 456)'}.
28
29 In addition to executing the specified code, input objects are passed
30 to the output stream.
31 """
32
33 import sys
34
35 import osh.args
36 import osh.core
37
38 # CLI
41
42 # API
44 """C{python_code} is executed. Any symbols defined by the execution of this
45 code are available to subsequent osh commands. Input objects are passed to
46 the output stream.
47 """
48 return _Py().process_args(python_code)
49
51
52 # object interface
53
56
57
58 # BaseOp interface
59
62
64 code = self.args().next_string()
65 before = globals().copy()
66 exec code in globals()
67 after = globals()
68 # Put new symbols in function.defined_by_osh
69 for key, value in after.iteritems():
70 if key not in before:
71 osh.core.add_to_namespace(key, value)
72
75
76
77 # Generator interface
78
81
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Oct 3 15:23:48 2010 | http://epydoc.sourceforge.net |