rest25/library/chunk.rst => rest262/library/chunk.rst
48the :class:`Chunk` class defined here is to instantiate an instance at the start
49of each chunk and read from the instance until it reaches the end, after which a
50new instance can be instantiated. At the end of the file, creating a new
51instance will fail with a :exc:`EOFError` exception.
52
53
54.. class:: Chunk(file[, align, bigendian, inclheader])
55
n56-   Class which represents a chunk.  The *file* argument is expected to be a file-
n56+   Class which represents a chunk.  The *file* argument is expected to be a
57-   like object.  An instance of this class is specifically allowed.  The only
57+   file-like object.  An instance of this class is specifically allowed.  The
58-   method that is needed is :meth:`read`.  If the methods :meth:`seek` and
58+   only method that is needed is :meth:`read`.  If the methods :meth:`seek` and
59-   :meth:`tell` are present and don't raise an exception, they are also used.  If
59+   :meth:`tell` are present and don't raise an exception, they are also used.
60-   these methods are present and raise an exception, they are expected to not have
60+   If these methods are present and raise an exception, they are expected to not
61-   altered the object.  If the optional argument *align* is true, chunks are
61+   have altered the object.  If the optional argument *align* is true, chunks
62-   assumed to be aligned on 2-byte boundaries.  If *align* is false, no alignment
62+   are assumed to be aligned on 2-byte boundaries.  If *align* is false, no
63-   is assumed.  The default value is true.  If the optional argument *bigendian* is
63+   alignment is assumed.  The default value is true.  If the optional argument
64-   false, the chunk size is assumed to be in little-endian order.  This is needed
64+   *bigendian* is false, the chunk size is assumed to be in little-endian order.
65-   for WAVE audio files. The default value is true.  If the optional argument
65+   This is needed for WAVE audio files. The default value is true.  If the
66-   *inclheader* is true, the size given in the chunk header includes the size of
66+   optional argument *inclheader* is true, the size given in the chunk header
67-   the header.  The default value is false.
67+   includes the size of the header.  The default value is false.
68
n69-A :class:`Chunk` object supports the following methods:
n69+   A :class:`Chunk` object supports the following methods:
70
71
n72-.. method:: Chunk.getname()
n72+   .. method:: getname()
73
n74-   Returns the name (ID) of the chunk.  This is the first 4 bytes of the chunk.
n74+      Returns the name (ID) of the chunk.  This is the first 4 bytes of the
75+      chunk.
75
76
n77-.. method:: Chunk.getsize()
n78+   .. method:: getsize()
78
n79-   Returns the size of the chunk.
n80+      Returns the size of the chunk.
80
81
n82-.. method:: Chunk.close()
n83+   .. method:: close()
83
n84-   Close and skip to the end of the chunk.  This does not close the underlying
n85+      Close and skip to the end of the chunk.  This does not close the
85-   file.
86+      underlying file.
86
n87-The remaining methods will raise :exc:`IOError` if called after the
n88+   The remaining methods will raise :exc:`IOError` if called after the
88-:meth:`close` method has been called.
89+   :meth:`close` method has been called.
89
90
n91-.. method:: Chunk.isatty()
n92+   .. method:: isatty()
92
n93-   Returns ``False``.
n94+      Returns ``False``.
94
95
n96-.. method:: Chunk.seek(pos[, whence])
n97+   .. method:: seek(pos[, whence])
97
n98-   Set the chunk's current position.  The *whence* argument is optional and
n99+      Set the chunk's current position.  The *whence* argument is optional and
99-   defaults to ``0`` (absolute file positioning); other values are ``1`` (seek
100+      defaults to ``0`` (absolute file positioning); other values are ``1``
100-   relative to the current position) and ``2`` (seek relative to the file's end).
101+      (seek relative to the current position) and ``2`` (seek relative to the
101-   There is no return value. If the underlying file does not allow seek, only
102+      file's end).  There is no return value. If the underlying file does not
102-   forward seeks are allowed.
103+      allow seek, only forward seeks are allowed.
103
104
n105-.. method:: Chunk.tell()
n106+   .. method:: tell()
106
n107-   Return the current position into the chunk.
n108+      Return the current position into the chunk.
108
109
n110-.. method:: Chunk.read([size])
n111+   .. method:: read([size])
111
n112-   Read at most *size* bytes from the chunk (less if the read hits the end of the
n113+      Read at most *size* bytes from the chunk (less if the read hits the end of
113-   chunk before obtaining *size* bytes).  If the *size* argument is negative or
114+      the chunk before obtaining *size* bytes).  If the *size* argument is
114-   omitted, read all data until the end of the chunk.  The bytes are returned as a
115+      negative or omitted, read all data until the end of the chunk.  The bytes
115-   string object.  An empty string is returned when the end of the chunk is
116+      are returned as a string object.  An empty string is returned when the end
116-   encountered immediately.
117+      of the chunk is encountered immediately.
117
118
n119-.. method:: Chunk.skip()
n120+   .. method:: skip()
120
t121-   Skip to the end of the chunk.  All further calls to :meth:`read` for the chunk
t122+      Skip to the end of the chunk.  All further calls to :meth:`read` for the
122-   will return ``''``.  If you are not interested in the contents of the chunk,
123+      chunk will return ``''``.  If you are not interested in the contents of
123-   this method should be called so that the file points to the start of the next
124+      the chunk, this method should be called so that the file points to the
124-   chunk.
125+      start of the next chunk.
126+ 
125
126.. rubric:: Footnotes
127
128.. [#] "EA IFF 85" Standard for Interchange Format Files, Jerry Morrison, Electronic
129   Arts, January 1985.
130
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op