|
| 1 | +/* Copyright (c) Jython Developers */ |
| 2 | +package org.python.modules.itertools; |
| 3 | +import org.python.core.ArgParser; |
| 4 | +import org.python.core.Py; |
| 5 | +import org.python.core.PyIterator; |
| 6 | +import org.python.core.PyObject; |
| 7 | +import org.python.core.PyString; |
| 8 | +import org.python.core.PyTuple; |
| 9 | +import org.python.core.PyType; |
| 10 | +import org.python.expose.ExposedClassMethod; |
| 11 | +import org.python.expose.ExposedGet; |
| 12 | +import org.python.expose.ExposedNew; |
| 13 | +import org.python.expose.ExposedMethod; |
| 14 | +import org.python.expose.ExposedType; |
| 15 | + |
| 16 | +import java.util.ArrayList; |
| 17 | + |
| 18 | +@ExposedType(name = "itertools.ifilterfalse", base = PyObject.class) |
| 19 | +public class ifilterfalse extends PyObject { |
| 20 | + |
| 21 | + public static final PyType TYPE = PyType.fromClass(ifilterfalse.class); |
| 22 | + private PyIterator iter; |
| 23 | + |
| 24 | + public ifilterfalse() { |
| 25 | + super(); |
| 26 | + } |
| 27 | + |
| 28 | + public ifilterfalse(PyType subType) { |
| 29 | + super(subType); |
| 30 | + } |
| 31 | + |
| 32 | + public ifilterfalse(PyObject predicate, PyObject iterable) { |
| 33 | + super(); |
| 34 | + ifilterfalse___init__(predicate, iterable); |
| 35 | + } |
| 36 | + |
| 37 | + @ExposedGet |
| 38 | + public static PyString __doc__ = new PyString( |
| 39 | + "'ifilterfalse(function or None, sequence) --> ifilterfalse object\n\n" |
| 40 | + + "Return those items of sequence for which function(item) is false.\nIf function is None, " |
| 41 | + + "return the items that are false.'"); |
| 42 | + |
| 43 | + /** |
| 44 | + * Creates an iterator that returns the items of the iterable for which |
| 45 | + * <code>predicate(item)</code> is <code>false</code>. If <code>predicate</code> is null |
| 46 | + * (None) return the items that are false. |
| 47 | + */ |
| 48 | + @ExposedNew |
| 49 | + @ExposedMethod |
| 50 | + final void ifilterfalse___init__(PyObject[] args, String[] kwds) { |
| 51 | + ArgParser ap = new ArgParser("ifilterfalse", args, kwds, "predicate", "iterable"); |
| 52 | + ap.noKeywords(); |
| 53 | + PyObject predicate = ap.getPyObject(0); |
| 54 | + PyObject iterable = ap.getPyObject(1); |
| 55 | + ifilterfalse___init__(predicate, iterable); |
| 56 | + } |
| 57 | + |
| 58 | + public void ifilterfalse___init__(PyObject predicate, PyObject iterable) { |
| 59 | + iter = new itertools.FilterIterator(predicate, iterable, false); |
| 60 | + } |
| 61 | + |
| 62 | + @ExposedMethod |
| 63 | + public PyObject __iter__() { |
| 64 | + return iter; |
| 65 | + } |
| 66 | + |
| 67 | + @ExposedMethod |
| 68 | + public PyObject next() { |
| 69 | + return iter.next(); |
| 70 | + } |
| 71 | + |
| 72 | +} |
0 commit comments