(no commit message)
[sfa.git] / server / jpywork / util.java
1 import org.python.core.*;
2
3 public class util extends java.lang.Object {
4     static String[] jpy$mainProperties = new String[] {"python.modules.builtin", "exceptions:org.python.core.exceptions"};
5     static String[] jpy$proxyProperties = new String[] {"python.modules.builtin", "exceptions:org.python.core.exceptions", "python.options.showJavaExceptions", "true"};
6     static String[] jpy$packages = new String[] {"java.net", null, "java.lang", null, "org.python.core", null, "java.io", null, "java.util.zip", null};
7     
8     public static class _PyInner extends PyFunctionTable implements PyRunnable {
9         private static PyObject s$0;
10         private static PyObject i$1;
11         private static PyObject i$2;
12         private static PyObject s$3;
13         private static PyObject s$4;
14         private static PyObject s$5;
15         private static PyObject s$6;
16         private static PyFunctionTable funcTable;
17         private static PyCode c$0_lookup;
18         private static PyCode c$1_getzip;
19         private static PyCode c$2_closezips;
20         private static PyCode c$3_findClass;
21         private static PyCode c$4_reportPublicPlainClasses;
22         private static PyCode c$5_openResource;
23         private static PyCode c$6_listAllClasses;
24         private static PyCode c$7_main;
25         private static void initConstants() {
26             s$0 = Py.newString(".");
27             i$1 = Py.newInteger(0);
28             i$2 = Py.newInteger(1);
29             s$3 = Py.newString("java class");
30             s$4 = Py.newString("__name__");
31             s$5 = Py.newString(",");
32             s$6 = Py.newString("/usr/share/jython/Tools/jythonc/util.py");
33             funcTable = new _PyInner();
34             c$0_lookup = Py.newCode(1, new String[] {"name", "top", "names"}, "/usr/share/jython/Tools/jythonc/util.py", "lookup", false, false, funcTable, 0, null, null, 0, 1);
35             c$1_getzip = Py.newCode(1, new String[] {"filename", "zipfile"}, "/usr/share/jython/Tools/jythonc/util.py", "getzip", false, false, funcTable, 1, null, null, 0, 1);
36             c$2_closezips = Py.newCode(0, new String[] {"zf"}, "/usr/share/jython/Tools/jythonc/util.py", "closezips", false, false, funcTable, 2, null, null, 0, 1);
37             c$3_findClass = Py.newCode(1, new String[] {"c"}, "/usr/share/jython/Tools/jythonc/util.py", "findClass", false, false, funcTable, 3, null, null, 0, 1);
38             c$4_reportPublicPlainClasses = Py.newCode(1, new String[] {"jpkg", "classes"}, "/usr/share/jython/Tools/jythonc/util.py", "reportPublicPlainClasses", false, false, funcTable, 4, null, null, 0, 1);
39             c$5_openResource = Py.newCode(1, new String[] {"res"}, "/usr/share/jython/Tools/jythonc/util.py", "openResource", false, false, funcTable, 5, null, null, 0, 1);
40             c$6_listAllClasses = Py.newCode(1, new String[] {"jpkg", "classes", "classes2", "pkg2"}, "/usr/share/jython/Tools/jythonc/util.py", "listAllClasses", false, false, funcTable, 6, null, null, 0, 1);
41             c$7_main = Py.newCode(0, new String[] {}, "/usr/share/jython/Tools/jythonc/util.py", "main", false, false, funcTable, 7, null, null, 0, 0);
42         }
43         
44         
45         public PyCode getMain() {
46             if (c$7_main == null) _PyInner.initConstants();
47             return c$7_main;
48         }
49         
50         public PyObject call_function(int index, PyFrame frame) {
51             switch (index){
52                 case 0:
53                 return _PyInner.lookup$1(frame);
54                 case 1:
55                 return _PyInner.getzip$2(frame);
56                 case 2:
57                 return _PyInner.closezips$3(frame);
58                 case 3:
59                 return _PyInner.findClass$4(frame);
60                 case 4:
61                 return _PyInner.reportPublicPlainClasses$5(frame);
62                 case 5:
63                 return _PyInner.openResource$6(frame);
64                 case 6:
65                 return _PyInner.listAllClasses$7(frame);
66                 case 7:
67                 return _PyInner.main$8(frame);
68                 default:
69                 return null;
70             }
71         }
72         
73         private static PyObject lookup$1(PyFrame frame) {
74             // Temporary Variables
75             int t$0$int;
76             PyObject t$0$PyObject, t$1$PyObject;
77             
78             // Code
79             frame.setlocal(2, frame.getlocal(0).invoke("split", s$0));
80             frame.setlocal(1, frame.getglobal("__import__").__call__(frame.getlocal(2).__getitem__(i$1)));
81             t$0$int = 0;
82             t$1$PyObject = frame.getlocal(2).__getslice__(i$2, null, null);
83             while ((t$0$PyObject = t$1$PyObject.__finditem__(t$0$int++)) != null) {
84                 frame.setlocal(0, t$0$PyObject);
85                 frame.setlocal(1, frame.getglobal("getattr").__call__(frame.getlocal(1), frame.getlocal(0)));
86             }
87             return frame.getlocal(1);
88         }
89         
90         private static PyObject getzip$2(PyFrame frame) {
91             if (frame.getglobal("zipfiles").invoke("has_key", frame.getlocal(0)).__nonzero__()) {
92                 return frame.getglobal("zipfiles").__getitem__(frame.getlocal(0));
93             }
94             frame.setlocal(1, frame.getglobal("ZipFile").__call__(frame.getlocal(0)));
95             frame.getglobal("zipfiles").__setitem__(frame.getlocal(0), frame.getlocal(1));
96             return frame.getlocal(1);
97         }
98         
99         private static PyObject closezips$3(PyFrame frame) {
100             // Temporary Variables
101             int t$0$int;
102             PyObject t$0$PyObject, t$1$PyObject;
103             
104             // Code
105             t$0$int = 0;
106             t$1$PyObject = frame.getglobal("zipfiles").invoke("values");
107             while ((t$0$PyObject = t$1$PyObject.__finditem__(t$0$int++)) != null) {
108                 frame.setlocal(0, t$0$PyObject);
109                 frame.getlocal(0).invoke("close");
110             }
111             frame.getglobal("zipfiles").invoke("clear");
112             return Py.None;
113         }
114         
115         private static PyObject findClass$4(PyFrame frame) {
116             return frame.getglobal("Py").__getattr__("findClassEx").__call__(frame.getlocal(0), s$3);
117         }
118         
119         private static PyObject reportPublicPlainClasses$5(PyFrame frame) {
120             frame.setlocal(1, frame.getglobal("sys").__getattr__("packageManager").__getattr__("doDir").__call__(frame.getlocal(0), i$1, i$2));
121             frame.getlocal(1).invoke("remove", s$4);
122             return frame.getglobal("string").__getattr__("join").__call__(frame.getlocal(1), s$5);
123         }
124         
125         private static PyObject openResource$6(PyFrame frame) {
126             // global _path_vfs
127             if (frame.getglobal("_path_vfs").__not__().__nonzero__()) {
128                 frame.setglobal("_path_vfs", frame.getglobal("PathVFS").__call__(frame.getglobal("sys").__getattr__("registry")));
129             }
130             return frame.getglobal("_path_vfs").invoke("open", frame.getlocal(0));
131         }
132         
133         private static PyObject listAllClasses$7(PyFrame frame) {
134             // global _ypm
135             frame.setlocal(1, frame.getglobal("sys").__getattr__("packageManager").__getattr__("doDir").__call__(frame.getlocal(0), i$1, i$2));
136             frame.getlocal(1).invoke("remove", s$4);
137             if (frame.getglobal("_ypm")._is(frame.getglobal("None")).__nonzero__()) {
138                 frame.setglobal("_ypm", frame.getglobal("YaPM").__call__(frame.getglobal("sys").__getattr__("registry")));
139             }
140             frame.setlocal(3, frame.getglobal("_ypm").invoke("lookupName", frame.getlocal(0).__getattr__("__name__")));
141             frame.setlocal(2, frame.getglobal("_ypm").invoke("doDir", new PyObject[] {frame.getlocal(3), i$1, i$2}));
142             frame.getlocal(2).invoke("remove", s$4);
143             frame.getlocal(1).invoke("extend", frame.getlocal(2));
144             return frame.getlocal(1);
145         }
146         
147         private static PyObject main$8(PyFrame frame) {
148             frame.setglobal("__file__", s$6);
149             
150             PyObject[] imp_accu;
151             // Code
152             frame.setlocal("lookup", new PyFunction(frame.f_globals, new PyObject[] {}, c$0_lookup));
153             imp_accu = org.python.core.imp.importFrom("java.util.zip", new String[] {"ZipFile"}, frame);
154             frame.setlocal("ZipFile", imp_accu[0]);
155             imp_accu = null;
156             frame.setlocal("zipfiles", new PyDictionary(new PyObject[] {}));
157             frame.setlocal("getzip", new PyFunction(frame.f_globals, new PyObject[] {}, c$1_getzip));
158             frame.setlocal("closezips", new PyFunction(frame.f_globals, new PyObject[] {}, c$2_closezips));
159             frame.setlocal("sys", org.python.core.imp.importOne("sys", frame));
160             frame.setlocal("string", org.python.core.imp.importOne("string", frame));
161             imp_accu = org.python.core.imp.importFrom("org.python.core", new String[] {"Py"}, frame);
162             frame.setlocal("Py", imp_accu[0]);
163             imp_accu = null;
164             imp_accu = org.python.core.imp.importFrom("yapm", new String[] {"YaPM"}, frame);
165             frame.setlocal("YaPM", imp_accu[0]);
166             imp_accu = null;
167             imp_accu = org.python.core.imp.importFrom("PathVFS", new String[] {"PathVFS"}, frame);
168             frame.setlocal("PathVFS", imp_accu[0]);
169             imp_accu = null;
170             frame.setlocal("findClass", new PyFunction(frame.f_globals, new PyObject[] {}, c$3_findClass));
171             frame.setlocal("reportPublicPlainClasses", new PyFunction(frame.f_globals, new PyObject[] {}, c$4_reportPublicPlainClasses));
172             frame.setlocal("_path_vfs", frame.getname("None"));
173             frame.setlocal("openResource", new PyFunction(frame.f_globals, new PyObject[] {}, c$5_openResource));
174             frame.setlocal("_ypm", frame.getname("None"));
175             frame.setlocal("listAllClasses", new PyFunction(frame.f_globals, new PyObject[] {}, c$6_listAllClasses));
176             return Py.None;
177         }
178         
179     }
180     public static void moduleDictInit(PyObject dict) {
181         dict.__setitem__("__name__", new PyString("util"));
182         Py.runCode(new _PyInner().getMain(), dict, dict);
183     }
184     
185     public static void main(String[] args) throws java.lang.Exception {
186         String[] newargs = new String[args.length+1];
187         newargs[0] = "util";
188         System.arraycopy(args, 0, newargs, 1, args.length);
189         Py.runMain(util._PyInner.class, newargs, util.jpy$packages, util.jpy$mainProperties, "", new String[] {"string", "random", "util", "traceback", "sre_compile", "atexit", "sre", "sre_constants", "StringIO", "javaos", "socket", "yapm", "calendar", "repr", "copy_reg", "SocketServer", "server", "re", "linecache", "javapath", "UserDict", "copy", "threading", "stat", "PathVFS", "sre_parse"});
190     }
191     
192 }