Package org.python.core

Examples of org.python.core.PyString


    }

    public PyObject __findattr__(String name) {
        PyType self_type = getType();
        PyObject getattribute = self_type.lookup("__getattribute__");
        PyString py_name = null;
        try {
            if (getattribute != null) {
                return getattribute.__get__(this, self_type).__call__(py_name = new PyString(name));
            } else {
                return super.__findattr__(name);
            }
        } catch (PyException e) {
            if (Py.matchException(e, Py.AttributeError)) {
                PyObject getattr = self_type.lookup("__getattr__");
                if (getattr != null)
                    try {
                        return getattr.__get__(this, self_type)
                                .__call__(py_name != null ? py_name : new PyString(name));
                    } catch (PyException e1) {
                        if (!Py.matchException(e1, Py.AttributeError))
                            throw e1;
                    }
                return null;
View Full Code Here


    public void __setattr__(String name, PyObject value) {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__setattr__");
        if (impl != null) {
            impl.__get__(this, self_type).__call__(new PyString(name), value);
            return;
        }
        super.__setattr__(name, value);
    }
View Full Code Here

    public void __delattr__(String name) {
        PyType self_type = getType();
        PyObject impl = self_type.lookup("__delattr__");
        if (impl != null) {
            impl.__get__(this, self_type).__call__(new PyString(name));
            return;
        }
        super.__delattr__(name);
    }
View Full Code Here

    private List<Metric> getMetrics(InputStream inputStream, BigInteger length) throws IOException {
        byte[] bytes = new byte[length.intValue()];
        inputStream.read(bytes);
        String payload = new String(bytes, ISO_8859_1);

        PyString pyString = new PyString(payload);
        PyList pyList = (PyList) cPickle.loads(pyString);

        return Lists.transform(pyList, new PythonToJava());
    }
View Full Code Here

  }

  @Override
  public void readFields(DataInput in) throws IOException {
    String str = WritableUtils.readString(in);
    PyString pyString = new PyString(str);
    Object object;
    try {
      object = cPickle.loads(pyString);
    } catch (PyException e) {
      LOG.fatal("Could not deserialize Jython value from string " + str);
View Full Code Here

    setPyObject((PyObject) object);
  }

  @Override
  public void write(DataOutput out) throws IOException {
    PyString pyString;
    try {
      pyString = cPickle.dumps(getPyObject());
    } catch (PyException e) {
      LOG.fatal("Could not serialize wrapped Jython value: " +
          getPyObject().__str__());
      throw e;
    }
    WritableUtils.writeString(out, pyString.getString());
  }
View Full Code Here

     *
     * @param name the name of the option
     * @param value the value of the option
     */
    public void setOption(String name, String value) {
        sosreport.invoke(SET_OPTION, new PyString(name), new PyString(value));
    }
View Full Code Here

     * Enables a flag-like option for sosreport.
     *
     * @param name the name of the option
     */
    public void enableOption(String name) {
        sosreport.invoke(SET_OPTION, new PyString(name));
    }
View Full Code Here

     * @param value the value of the variable, must be adaptable by Jython
     */
    public void setGlobal(String name, Object value) {
        if (value != null) {
            ClassicPyObjectAdapter adapter = new ClassicPyObjectAdapter();
            sosreport.invoke(SET_GLOBAL, new PyString(name), adapter.adapt(value));
        }
    }
View Full Code Here

        String format = args[0].toString();

        FormatDef[] f = whichtable(format);
        int size = calcsize(format, f);
       
        return new PyString(pack(format, f, size, 1, args).toString());
    }
View Full Code Here

TOP

Related Classes of org.python.core.PyString

Copyright © 2018 www.massapicom. 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.