Examples of PyString


Examples of org.python.core.PyString

    {
        PySystemState systemState = new PySystemState();

        if (xmlReportFile != null)
        {
            systemState.argv.append(new PyString("--xml"));
            systemState.argv.append(new PyString(xmlReportFile));
        }

        if(ignoreFile == null)
        {
            ignoreFile = System.getProperty(IGNORE_FILE_SYSTEM_PROPERTY);
        }

        if(ignoreFile != null)
        {
            systemState.argv.append(new PyString("-I"));
            systemState.argv.append(new PyString(ignoreFile));
        }

        String testPattern = System.getProperty(TEST_PATTERN_SYSTEM_PROPERTY);
        if(testPattern != null)
        {
            systemState.argv.append(new PyString(testPattern));
        }

        if(Boolean.getBoolean(ALWAYS_COLORIZE_SYSTEM_PROPERTY))
        {
            systemState.argv.append(new PyString("--always-colorize"));
        }

        PythonInterpreter interp = new PythonInterpreter(null, systemState);
        return interp;
    }
View Full Code Here

Examples of org.python.core.PyString

            if (!prefix.isEmpty()) {
                metricName.insert(0, prefix);
            }
            metricName.append(".").append(valueName);

            PyTuple tuple = new PyTuple(new PyString(metricName.toString()),
                new PyTuple(new PyLong(timestamp), new PyString(value)));
            metrics.add(tuple);
            if(metrics.size() >= batchSize) {
                writeMetrics();
            }
        }
View Full Code Here

Examples of org.python.core.PyString

        }

        // Scalars are marshalled to PyString.
        if(model instanceof TemplateScalarModel)
        {
            return new PyString(((TemplateScalarModel)model).getAsString());
        }
       
        // Numbers are wrapped to Python built-in numeric types.
        if(model instanceof TemplateNumberModel)
        {
View Full Code Here

Examples of org.python.core.PyString

                    .append(metricName)
                    .append(".")
                    .append(valueName)
                    .toString();
            }
            PyTuple tuple = new PyTuple(new PyString(metricName),
                new PyTuple(new PyLong(timestamp), new PyString(value)));
            metrics.add(tuple);
            if(metrics.size() >= batchSize) {
                writeMetrics();
            }
        }
View Full Code Here

Examples of org.python.core.PyString

            int beginIndex;
            if ((beginIndex = filename.lastIndexOf(File.separator)) != -1) {
                filename = filename.substring(beginIndex + 1);
            }

            locals.__setitem__("__name__", new PyString(filename));
            locals.__setitem__("zipfile", Py.java2py(zip));

            InputStream file = zip.getInputStream(runit);
            PyCode code;
            try {
View Full Code Here

Examples of org.python.core.PyString

        interp.setLocals(mod.__dict__);
        //System.err.println("imp");

        for (int i = 0; i < opts.warnoptions.size(); i++) {
            String wopt = (String) opts.warnoptions.elementAt(i);
            PySystemState.warnoptions.append(new PyString(wopt));
        }

        String msg = "";
        if (Options.importSite) {
            try {
                imp.load("site");

                if (opts.notice) {
                    PyObject builtins = Py.getSystemState().builtins;
                    boolean copyright = builtins.__finditem__("copyright") != null;
                    boolean credits = builtins.__finditem__("credits") != null;
                    boolean license = builtins.__finditem__("license") != null;
                    if (copyright) {
                        msg += "\"copyright\"";
                        if (credits && license)
                            msg += ", ";
                        else if (credits || license)
                            msg += " or ";
                    }
                    if (credits) {
                        msg += "\"credits\"";
                        if (license)
                            msg += " or ";
                    }
                    if (license)
                        msg += "\"license\"";
                    if (msg.length() > 0)
                        System.err.println("Type " + msg + " for more information.");
                }
            } catch (PyException pye) {
                if (!Py.matchException(pye, Py.ImportError)) {
                    System.err.println("error importing site");
                    Py.printException(pye);
                    System.exit(-1);
                }
            }
        }

        if (opts.division != null) {
            if ("old".equals(opts.division))
                Options.divisionWarning = 0;
            else if ("warn".equals(opts.division))
                Options.divisionWarning = 1;
            else if ("warnall".equals(opts.division))
                Options.divisionWarning = 2;
            else if ("new".equals(opts.division)) {
                Options.Qnew = true;
                interp.cflags.division = true;
            }
        }

        // was there a filename on the command line?
        if (opts.filename != null) {
            String path = new java.io.File(opts.filename).getParent();
            if (path == null)
                path = "";
            Py.getSystemState().path.insert(0, new PyString(path));
            if (opts.jar) {
                runJar(opts.filename);
            } else if (opts.filename.equals("-")) {
                try {
                    throw new RuntimeException("Can not run from <stdin> in internal PyDev version.");
                    //                    interp.locals.__setitem__(new PyString("__file__"),
                    //                                              new PyString("<stdin>"));
                    //                    interp.execfile(System.in, "<stdin>");
                } catch (Throwable t) {
                    Py.printException(t);
                }
            } else {
                try {
                    interp.locals.__setitem__(new PyString("__file__"), new PyString(opts.filename));
                    interp.execfile(opts.filename);
                } catch (Throwable t) {
                    Py.printException(t);
                    if (!opts.interactive) {
                        interp.cleanup();
                        System.exit(-1);
                    }
                }
            }
        } else {
            // if there was no file name on the command line, then "" is
            // the first element on sys.path.  This is here because if
            // there /was/ a filename on the c.l., and say the -i option
            // was given, sys.path[0] will have gotten filled in with the
            // dir of the argument filename.
            Py.getSystemState().path.insert(0, new PyString(""));

            if (opts.command != null) {
                try {
                    interp.exec(opts.command);
                } catch (Throwable t) {
View Full Code Here

Examples of org.python.core.PyString

            opencheck();
            int total = 0;
            PyList lines = new PyList();
            String line = readline();
            while (line.length() > 0) {
                lines.append(new PyString(line));
                total += line.length();
                if (0 < sizehint && sizehint <= total)
                    break;
                line = readline();
            }
View Full Code Here

Examples of org.python.core.PyString

                continue;
            }
            return new PyTuple(
                    new PyObject[] {
                            mi.file,
                            new PyString(mi.filename),
                            new PyTuple(new PyObject[] { new PyString(mi.suffix), new PyString(mi.mode),
                                    Py.newInteger(mi.type) }), });
        }
        throw Py.ImportError("No module named " + name);
    }
View Full Code Here

Examples of org.python.core.PyString

                    m.__dict__.__setitem__("__path__", new PyList(new PyObject[] { filename }));
                    m.__dict__.__setitem__("__file__", filename);
                    ModuleInfo mi = findFromSource(name, filename, true);
                    type = mi.type;
                    file = mi.file;
                    filename = new PyString(mi.filename);
                    break;
                default:
                    throw Py.ImportError("No module named " + name);
            }
        }
View Full Code Here

Examples of org.python.core.PyString

    public static PyObject get_suffixes() {
        return new PyList(
                new PyObject[] {
                        new PyTuple(
                                new PyObject[] { new PyString(".py"), new PyString("r"), Py.newInteger(PY_SOURCE), }),
                        new PyTuple(new PyObject[] { new PyString(".class"), new PyString("rb"),
                                Py.newInteger(PY_COMPILED), }), });
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.