Package org.python.core

Examples of org.python.core.ArgParser


        }

        @ExposedNew
        public static PyObject ScalarField_new(PyNewWrapper new_, boolean init, PyType subtype,
            PyObject[] args, String[] keywords) {
            ArgParser ap = new ArgParser("__init__", args, keywords, new String[] { "name", "type", "offset"});

            return new ScalarField(ap.getPyObject(0), CType.typeOf(ap.getPyObject(1)), ap.getInt(2));
        }
View Full Code Here


        }

        @ExposedNew
        final static PyObject itemgetter___new__(PyNewWrapper new_, boolean init, PyType subtype,
                                                 PyObject[] args, String[] keywords) {
            ArgParser ap = new ArgParser("itemgetter", args, keywords, "attr");
            ap.noKeywords();
            ap.getPyObject(0);
            return new PyItemGetter(args);
        }
View Full Code Here

            return itemgetter___call__(args, keywords);
        }

        @ExposedMethod
        final PyObject itemgetter___call__(PyObject[] args, String[] keywords) {
            ArgParser ap = new ArgParser("itemgetter", args, Py.NoKeywords, "obj");
            PyObject obj = ap.getPyObject(0);

            if (items.length == 1) {
                return obj.__getitem__(items[0]);
            }
View Full Code Here

        this(TYPE);
    }
    @ExposedNew
    @ExposedMethod
    public void Global___init__(PyObject[] args, String[] keywords) {
        ArgParser ap = new ArgParser("Global", args, keywords, new String[]
            {"names", "lineno", "col_offset"}, 1, true);
        setNames(ap.getPyObject(0, Py.None));
        int lin = ap.getInt(1, -1);
        if (lin != -1) {
            setLineno(lin);
        }

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

    }
View Full Code Here

        this(TYPE);
    }
    @ExposedNew
    @ExposedMethod
    public void GeneratorExp___init__(PyObject[] args, String[] keywords) {
        ArgParser ap = new ArgParser("GeneratorExp", args, keywords, new String[]
            {"elt", "generators", "lineno", "col_offset"}, 2, true);
        setElt(ap.getPyObject(0, Py.None));
        setGenerators(ap.getPyObject(1, Py.None));
        int lin = ap.getInt(2, -1);
        if (lin != -1) {
            setLineno(lin);
        }

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

    }
View Full Code Here

    }

    @ExposedNew
    final static PyObject Dialect___new__(PyNewWrapper new_, boolean init, PyType subtype,
                                          PyObject[] args, String[] keywords) {
        ArgParser ap = new ArgParser("__new__", args, keywords,
                                     new String[] {"dialect", "delimiter", "doublequote",
                                                   "escapechar", "lineterminator", "quotechar",
                                                   "quoting", "skipinitialspace", "strict"});
        PyObject dialect = ap.getPyObject(0, null);
        PyObject delimiter = ap.getPyObject(1, null);
        PyObject doublequote = ap.getPyObject(2, null);
        PyObject escapechar = ap.getPyObject(3, null);
        PyObject lineterminator = ap.getPyObject(4, null);
        PyObject quotechar = ap.getPyObject(5, null);
        PyObject quoting = ap.getPyObject(6, null);
        PyObject skipinitialspace = ap.getPyObject(7, null);
        PyObject strict = ap.getPyObject(8, null);

        if (dialect instanceof PyString) {
            dialect = _csv.get_dialect_from_registry(dialect);
        }
View Full Code Here

        int argc = args.length - keywords.length;
        if (argc > 2) {
            throw Py.TypeError("register_dialect() expected at most 2 arguments, got " + argc);
        }

        ArgParser ap = parseArgs("register_dialect", args, keywords);
        PyObject name = ap.getPyObject(0);
        PyObject dialect = ap.getPyObject(1, null);

        if (!(name instanceof PyBaseString)) {
            throw Py.TypeError("dialect name must be a string or unicode");
        }
View Full Code Here

    public static PyObject list_dialects() {
        return _dialects.keys();
    }

    public static PyObject reader(PyObject[] args, String[] keywords) {
        ArgParser ap = parseArgs("reader", args, keywords);
        PyObject iterator = Py.iter(ap.getPyObject(0), "argument 1 must be an iterator");
        PyObject dialect = ap.getPyObject(1, null);
        return new PyReader(iterator, dialectFromKwargs(dialect, args, keywords));
    }
View Full Code Here

        PyObject dialect = ap.getPyObject(1, null);
        return new PyReader(iterator, dialectFromKwargs(dialect, args, keywords));
    }

    public static PyObject writer(PyObject[] args, String[] keywords) {
        ArgParser ap = parseArgs("writer", args, keywords);
        PyObject outputFile = ap.getPyObject(0);
        PyObject dialect = ap.getPyObject(1, null);

        PyObject writeline = outputFile.__findattr__("write");
        if (writeline == null || !writeline.isCallable()) {
            throw Py.TypeError("argument 1 must have a \"write\" method");
        }
View Full Code Here

            int argc = args.length - keywords.length;
            PyObject[] justArgs = new PyObject[argc];
            System.arraycopy(args, 0, justArgs, 0, argc);
            args = justArgs;
        }
        return new ArgParser(funcName, args, Py.NoKeywords, Py.NoKeywords);
    }
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.