package org.cafebabepy.runtime.module.sys;

import org.cafebabepy.runtime.PyObject;
import org.cafebabepy.runtime.Python;
import org.cafebabepy.runtime.module.AbstractCafeBabePyModule;
import org.cafebabepy.runtime.module.DefinePyModule;
import org.cafebabepy.runtime.object.java.PyDictObject;

/**
 * Created by yotchang4s on 2017/06/03.
 */
@DefinePyModule(name = "sys")
public class PySysModule extends AbstractCafeBabePyModule {

    public PySysModule(Python runtime) {
        super(runtime);
    }

    protected void defineModule() {

    }

    @Override
    public void initialize() {
        super.initialize();

        PyDictObject modules = new PyDictObject(this.runtime, this.runtime.getSysModuleMap());
        getScope().put(this.runtime.str("modules"), modules);

        this.runtime.defineModule(this);

        PyObject version_info = this.runtime.newPyObject("sys.version_info", false);
        getScope().put(this.runtime.str("version_info"), version_info);
    }
}

@@ -288,16 +288,49 @@
 bject;%0A%0A
+import java.util.LinkedHashMap;%0A%0A
 /**%0A * C
@@ -1006,16 +1006,1566 @@
 n_info);
+%0A%0A        String os_arch = System.getProperty(%22os.arch%22);%0A        String os_name = System.getProperty(%22os.name%22).replaceAll(%22%C2%A5s+%22, %22-%22).toLowerCase();%0A%0A        String _multiarch = os_arch + %22-%22 + os_name;%0A        String cache_tag = Python.APPLICATION_NAME + %22-%22 + Python.MAJOR + Python.MINOR;%0A%0A        int release = 0x0f;%0A        switch (Python.RELEASE_LEVEL) %7B%0A            case %22final%22:%0A                release = 0x0f;%0A                break;%0A%0A            case %22candidate%22:%0A                release = 0x0c;%0A%0A            case %22beta%22:%0A                release = 0x0b;%0A                break;%0A%0A            case %22alpha%22:%0A                release = 0x0a;%0A                break;%0A        %7D%0A%0A        String hexversionStr = String.format(%22%2502x%2502x%2502x%2501x%2501x%22, Python.MAJOR, Python.MINOR, Python.MICRO, release, Python.SERIAL);%0A        int hexversion = Integer.parseInt(hexversionStr, 16);%0A%0A        LinkedHashMap%3CString, PyObject%3E simpleNamespaceMap = new LinkedHashMap%3C%3E();%0A        simpleNamespaceMap.put(%22_multiarch%22, this.runtime.str(_multiarch));%0A        simpleNamespaceMap.put(%22cache_tag%22, this.runtime.str(cache_tag));%0A        simpleNamespaceMap.put(%22hexversion%22, this.runtime.number(hexversion));%0A        simpleNamespaceMap.put(%22name%22, this.runtime.str(Python.APPLICATION_NAME));%0A        simpleNamespaceMap.put(%22version%22, version_info);%0A%0A        PyObject implementation = this.runtime.newPyObject(%22SimpleNamespace%22,%0A                new PyObject%5B0%5D, simpleNamespaceMap%0A        );%0A%0A        getScope().put(this.runtime.str(%22implementation%22), implementation);
 %0A    %7D%0A%7D

Add sys.implementation