From 5d86cfd98437eaa2b84b07ba19d51d50d64bc53f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 12 May 2015 14:07:48 +0200 Subject: Missing optional lib --- lib/Python/Lib/PIL/ImageSequence.py | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/Python/Lib/PIL/ImageSequence.py (limited to 'lib/Python/Lib/PIL/ImageSequence.py') diff --git a/lib/Python/Lib/PIL/ImageSequence.py b/lib/Python/Lib/PIL/ImageSequence.py new file mode 100644 index 000000000..dd01e2902 --- /dev/null +++ b/lib/Python/Lib/PIL/ImageSequence.py @@ -0,0 +1,42 @@ +# +# The Python Imaging Library. +# $Id$ +# +# sequence support classes +# +# history: +# 1997-02-20 fl Created +# +# Copyright (c) 1997 by Secret Labs AB. +# Copyright (c) 1997 by Fredrik Lundh. +# +# See the README file for information on usage and redistribution. +# + +## + + +class Iterator: + """ + This class implements an iterator object that can be used to loop + over an image sequence. + + You can use the ``[]`` operator to access elements by index. This operator + will raise an :py:exc:`IndexError` if you try to access a nonexistent + frame. + + :param im: An image object. + """ + + def __init__(self, im): + if not hasattr(im, "seek"): + raise AttributeError("im must have seek method") + self.im = im + + def __getitem__(self, ix): + try: + if ix: + self.im.seek(ix) + return self.im + except EOFError: + raise IndexError # end of sequence -- cgit v1.2.3