Package org.python.core

Examples of org.python.core.ArgParser


    }

    @ExposedNew
    @ExposedMethod
    final void zipimporter___init__(PyObject[] args, String[] kwds) {
        ArgParser ap = new ArgParser("__init__", args, kwds, new String[] {"path"});
        String path = ap.getString(0);
        zipimporter___init__(path);
    }
View Full Code Here


        return val;
    }

    public static PyString a2b_qp(PyObject[] arg, String[] kws)
    {
        ArgParser ap = new ArgParser("a2b_qp", arg, kws, new String[] {"s", "header"});
        String s = ap.getString(0);
        StringBuilder sb = new StringBuilder();
        boolean header = getIntFlagAsBool(ap, 1, 0, "an integer is required");

        if (header)
          s = UNDERSCORE.matcher(s).replaceAll(" ");
View Full Code Here

        + "On encoding, when istext is set, newlines are not encoded, and white\n"
        + "space at end of lines is.  When istext is not set, \r and \n (CR/LF) are\n"
        + "both encoded.  When quotetabs is set, space and tabs are encoded.");

    public static PyString b2a_qp(PyObject[] arg, String[] kws) {
        ArgParser ap = new ArgParser("b2a_qp", arg, kws, new String[] {"s", "quotetabs", "istext", "header"});
        String s = ap.getString(0);
        boolean quotetabs = getIntFlagAsBool(ap, 1, 0, "an integer is required");
        boolean istext = getIntFlagAsBool(ap, 2, 1, "an integer is required");
        boolean header = getIntFlagAsBool(ap, 3, 0, "an integer is required");

        String lineEnd;
View Full Code Here

    }

    @ExposedNew
    static PyObject stat_result_new(PyNewWrapper wrapper, boolean init, PyType subtype,
                                    PyObject[] args, String[] keywords) {
        ArgParser ap = new ArgParser("stat_result", args, keywords, new String[] {"tuple"}, 1);
        PyObject obj = ap.getPyObject(0);
        if (obj instanceof PyTuple) {
            if (obj.__len__() != n_fields) {
                String msg = String.format("stat_result() takes a %s-sequence (%s-sequence given)",
                                           n_fields, obj.__len__());
                throw Py.TypeError(msg);
View Full Code Here

        this(TYPE);
    }
    @ExposedNew
    @ExposedMethod
    public void Interactive___init__(PyObject[] args, String[] keywords) {
        ArgParser ap = new ArgParser("Interactive", args, keywords, new String[]
            {"body"}, 1, true);
        setBody(ap.getPyObject(0, Py.None));
    }
View Full Code Here

    /**
     * Create an iterator which returns the pair (key, sub-iterator) grouped by key(value).
     */
    public static PyIterator groupby(PyObject [] args, String [] kws) {
        ArgParser ap = new ArgParser("groupby", args, kws, "iterable", "key");
        if(args.length > 2){
            throw Py.TypeError("groupby takes two arguments, iterable and key");
        }
        PyObject iterable = ap.getPyObject(0);
        PyObject key = ap.getPyObject(1, null);
        return new GroupBy(iterable, key);
    }
View Full Code Here

            return new PyTuple(result);
        }
    }

    public PyObject groups(PyObject[] args, String[] kws) {
        ArgParser ap = new ArgParser("groups", args, kws, "default");
        PyObject def = ap.getPyObject(0, Py.None);

        PyObject[] result = new PyObject[groups-1];
        for (int i = 1; i < groups; i++) {
            result[i-1] = getslice_by_index(i, def);
        }
View Full Code Here

        }
        return new PyTuple(result);
    }

    public PyObject groupdict(PyObject[] args, String[] kws) {
        ArgParser ap = new ArgParser("groupdict", args, kws, "default");
        PyObject def = ap.getPyObject(0, Py.None);

        PyObject result = new PyDictionary();

        if (pattern.groupindex == null)
            return result;
View Full Code Here

        this(TYPE);
    }
    @ExposedNew
    @ExposedMethod
    public void comprehension___init__(PyObject[] args, String[] keywords) {
        ArgParser ap = new ArgParser("comprehension", args, keywords, new String[]
            {"target", "iter", "ifs"}, 3, true);
        setTarget(ap.getPyObject(0, Py.None));
        setIter(ap.getPyObject(1, Py.None));
        setIfs(ap.getPyObject(2, Py.None));
    }
View Full Code Here

        super(subType);
    }
    @ExposedNew
    @ExposedMethod
    public void Continue___init__(PyObject[] args, String[] keywords) {
        ArgParser ap = new ArgParser("Continue", args, keywords, new String[]
            {"lineno", "col_offset"}, 0, true);
        int lin = ap.getInt(0, -1);
        if (lin != -1) {
            setLineno(lin);
        }

        int col = ap.getInt(1, -1);
        if (col != -1) {
            setLineno(col);
        }

    }
View Full Code Here

TOP

Related Classes of org.python.core.ArgParser

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.