01: // Copyright (c) Corporation for National Research Initiatives
02: package org.python.modules;
03:
04: import org.python.core.*;
05:
06: public class os implements ClassDictInit {
07: public static String[] __depends__ = new String[] { "javaos", };
08:
09: // An ugly hack, but it keeps the site.py from CPython2.0 happy
10:
11: public static void classDictInit(PyObject dict) {
12:
13: // Fake from javaos import *
14:
15: PyTuple all = new PyTuple(new PyString[] { Py.newString('*') });
16: PyObject module = __builtin__.__import__("javaos", null, null,
17: all);
18:
19: PyObject names = module.__dir__();
20: PyObject name;
21: for (int i = 0; (name = names.__finditem__(i)) != null; i++) {
22: String sname = name.toString().intern();
23: dict.__setitem__(name, module.__getattr__(sname));
24: }
25:
26: String prefix = Py.getSystemState().prefix;
27: if (prefix != null) {
28: String libdir = prefix + "/Lib/javaos.py";
29: dict.__setitem__("__file__", new PyString(libdir));
30: }
31: }
32: }
|