KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > modules > os


1 // Copyright (c) Corporation for National Research Initiatives
2
package org.python.modules;
3
4 import org.python.core.*;
5
6 public class os implements ClassDictInit {
7     public static String JavaDoc[] __depends__ = new String JavaDoc[] {"javaos", };
8
9     // 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, all);
17
18         PyObject names = module.__dir__();
19         PyObject name;
20         for (int i = 0; (name=names.__finditem__(i)) != null; i++) {
21             String JavaDoc sname = name.toString().intern();
22             dict.__setitem__(name, module.__getattr__(sname));
23         }
24
25         String JavaDoc prefix = Py.getSystemState().prefix;
26         if (prefix != null) {
27             String JavaDoc libdir = prefix + "/Lib/javaos.py";
28             dict.__setitem__("__file__", new PyString(libdir));
29         }
30     }
31 }
32
Popular Tags