<commit_before># [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata)

The [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) type provides a window over a section of the input stream object, where the window starts at the stream position corresponding to the start of the chunk's data and ends after the final byte of chunk data. Note that reading to the end of the chunk data will not necessarily correspond to the end of the input stream, but the [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object will still behave as if it had reached the EOF.

A [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object has the same interface as a read-only [`io.RawIOBase`](https://docs.python.org/library/io.html#io.RawIOBase) object. It will delegate to the corresponding methods on the input stream in most cases, with some additional constraints. The properties and methods that form the [`io.RawIOBase`](https://docs.python.org/library/io.html#io.RawIOBase) interface are listed below.

- [`<riff.ChunkData>.close`](riff.ChunkData.md#riffchunkdataclose)
- [`<riff.ChunkData>.closed`](riff.ChunkData.md#riffchunkdataclosed)
- [`<riff.ChunkData>.fileno`](riff.ChunkData.md#riffchunkdatafileno)
- [`<riff.ChunkData>.flush`](riff.ChunkData.md#riffchunkdataflush)
- [`<riff.ChunkData>.isatty`](riff.ChunkData.md#riffchunkdataisatty)
- [`<riff.ChunkData>.read`](riff.ChunkData.md#riffchunkdataread)
- [`<riff.ChunkData>.readable`](riff.ChunkData.md#riffchunkdatareadable)
- [`<riff.ChunkData>.readall`](riff.ChunkData.md#riffchunkdatareadall)
- [`<riff.ChunkData>.readinto`](riff.ChunkData.md#riffchunkdatareadinto)
- [`<riff.ChunkData>.readline`](riff.ChunkData.md#riffchunkdatareadline)
- [`<riff.ChunkData>.readlines`](riff.ChunkData.md#riffchunkdatareadlines)
- [`<riff.ChunkData>.seek`](riff.ChunkData.md#riffchunkdataseek)
- [`<riff.ChunkData>.seekable`](riff.ChunkData.md#riffchunkdataseekable)
- [`<riff.ChunkData>.tell`](riff.ChunkData.md#riffchunkdatatell)
- [`<riff.ChunkData>.truncate`](riff.ChunkData.md#riffchunkdatatruncate)
- [`<riff.ChunkData>.writable`](riff.ChunkData.md#riffchunkdatawritable)
- [`<riff.ChunkData>.write`](riff.ChunkData.md#riffchunkdatawrite)
- [`<riff.ChunkData>.writelines`](riff.ChunkData.md#riffchunkdatawritelines)

As well as those defined by the [`io.RawIOBase`](https://docs.python.org/library/io.html#io.RawIOBase) interface, a [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object defines the following additional properties and methods:

- [`<riff.ChunkData>.padded`](riff.ChunkData.md#riffchunkdatapadded)
- [`<riff.ChunkData>.size`](riff.ChunkData.md#riffchunkdatasize)
- [`<riff.ChunkData>.skip`](riff.ChunkData.md#riffchunkdataskip)


## [`<riff.ChunkData>.close`](riff.ChunkData.md#riffchunkdataclose)

Calling the `close` method on a [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object prevents further stream operations from being performed. Operations called subsequently will raise a [`ValueError`](https://docs.python.org/library/exceptions.html#ValueError).

```python
>>> import io
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> import riff
>>> chunk = riff.Chunk.read(stream)
>>> chunk.data.read(4)
b'Test'
>>> chunk.data.close()
>>> chunk.data.read(4)
Traceback (most recent call last):
  ...
ValueError: chunk data closed
>>>
```

Closing the chunk data stream does not close the input stream, only the [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object itself.

```python
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> chunk = riff.Chunk.read(stream)
>>> chunk.data.read(4)
b'Test'
>>> chunk.data.close()
>>> stream.closed
False
>>> stream.read(4)
b'Data'
>>>
```

If the input stream is closed, the [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object will also behave as if closed.

```python
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> chunk = riff.Chunk.read(stream)
>>> chunk.data.read(4)
b'Test'
>>> stream.close()
>>> chunk.data.read(4)
Traceback (most recent call last):
  ...
ValueError: chunk data closed
>>>
```


## [`<riff.ChunkData>.closed`](riff.ChunkData.md#riffchunkdataclosed)

Not yet documented.


## [`<riff.ChunkData>.fileno`](riff.ChunkData.md#riffchunkdatafileno)

Not yet documented.


## [`<riff.ChunkData>.flush`](riff.ChunkData.md#riffchunkdataflush)

Not yet documented.


## [`<riff.ChunkData>.isatty`](riff.ChunkData.md#riffchunkdataisatty)

Not yet documented.


## [`<riff.ChunkData>.padded`](riff.ChunkData.md#riffchunkdatapadded)

The `padded` property of a [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object indicates whether the chunk requires a pad byte at the end of the data block. This will be `True` if the chunk size is odd, and `False` if the chunk size is even.

```python
>>> import io
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> import riff<commit_msg>Add docs for closed property<commit_after># [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata)

The [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) type provides a window over a section of the input stream object, where the window starts at the stream position corresponding to the start of the chunk's data and ends after the final byte of chunk data. Note that reading to the end of the chunk data will not necessarily correspond to the end of the input stream, but the [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object will still behave as if it had reached the EOF.

A [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object has the same interface as a read-only [`io.RawIOBase`](https://docs.python.org/library/io.html#io.RawIOBase) object. It will delegate to the corresponding methods on the input stream in most cases, with some additional constraints. The properties and methods that form the [`io.RawIOBase`](https://docs.python.org/library/io.html#io.RawIOBase) interface are listed below.

- [`<riff.ChunkData>.close`](riff.ChunkData.md#riffchunkdataclose)
- [`<riff.ChunkData>.closed`](riff.ChunkData.md#riffchunkdataclosed)
- [`<riff.ChunkData>.fileno`](riff.ChunkData.md#riffchunkdatafileno)
- [`<riff.ChunkData>.flush`](riff.ChunkData.md#riffchunkdataflush)
- [`<riff.ChunkData>.isatty`](riff.ChunkData.md#riffchunkdataisatty)
- [`<riff.ChunkData>.read`](riff.ChunkData.md#riffchunkdataread)
- [`<riff.ChunkData>.readable`](riff.ChunkData.md#riffchunkdatareadable)
- [`<riff.ChunkData>.readall`](riff.ChunkData.md#riffchunkdatareadall)
- [`<riff.ChunkData>.readinto`](riff.ChunkData.md#riffchunkdatareadinto)
- [`<riff.ChunkData>.readline`](riff.ChunkData.md#riffchunkdatareadline)
- [`<riff.ChunkData>.readlines`](riff.ChunkData.md#riffchunkdatareadlines)
- [`<riff.ChunkData>.seek`](riff.ChunkData.md#riffchunkdataseek)
- [`<riff.ChunkData>.seekable`](riff.ChunkData.md#riffchunkdataseekable)
- [`<riff.ChunkData>.tell`](riff.ChunkData.md#riffchunkdatatell)
- [`<riff.ChunkData>.truncate`](riff.ChunkData.md#riffchunkdatatruncate)
- [`<riff.ChunkData>.writable`](riff.ChunkData.md#riffchunkdatawritable)
- [`<riff.ChunkData>.write`](riff.ChunkData.md#riffchunkdatawrite)
- [`<riff.ChunkData>.writelines`](riff.ChunkData.md#riffchunkdatawritelines)

As well as those defined by the [`io.RawIOBase`](https://docs.python.org/library/io.html#io.RawIOBase) interface, a [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object defines the following additional properties and methods:

- [`<riff.ChunkData>.padded`](riff.ChunkData.md#riffchunkdatapadded)
- [`<riff.ChunkData>.size`](riff.ChunkData.md#riffchunkdatasize)
- [`<riff.ChunkData>.skip`](riff.ChunkData.md#riffchunkdataskip)


## [`<riff.ChunkData>.close`](riff.ChunkData.md#riffchunkdataclose)

Calling the `close` method on a [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object prevents further stream operations from being performed. Operations called subsequently will raise a [`ValueError`](https://docs.python.org/library/exceptions.html#ValueError).

```python
>>> import io
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> import riff
>>> chunk = riff.Chunk.read(stream)
>>> chunk.data.read(4)
b'Test'
>>> chunk.data.close()
>>> chunk.data.read(4)
Traceback (most recent call last):
  ...
ValueError: chunk data closed
>>>
```

Closing the chunk data stream does not close the input stream, only the [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object itself.

```python
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> chunk = riff.Chunk.read(stream)
>>> chunk.data.read(4)
b'Test'
>>> chunk.data.close()
>>> stream.closed
False
>>> stream.read(4)
b'Data'
>>>
```

If the input stream is closed, the [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object will also behave as if closed.

```python
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> chunk = riff.Chunk.read(stream)
>>> chunk.data.read(4)
b'Test'
>>> stream.close()
>>> chunk.data.read(4)
Traceback (most recent call last):
  ...
ValueError: chunk data closed
>>>
```


## [`<riff.ChunkData>.closed`](riff.ChunkData.md#riffchunkdataclosed)

The `closed` propety of a [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object indicates whether the data stream has been closed using the [`<riff.ChunkData>.close`](riff.ChunkData.md#riffchunkdataclose) method.

```python
>>> import io
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> import riff
>>> chunk = riff.Chunk.read(stream)
>>> chunk.data.closed
False
>>> chunk.data.close()
>>> chunk.data.closed
True
>>>
```

The [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object will also show as closed if the input stream is closed.

```python
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> chunk = riff.Chunk.read(stream)
>>> stream.close()
>>> chunk.data.closed
True
>>>
```


## [`<riff.ChunkData>.fileno`](riff.ChunkData.md#riffchunkdatafileno)

Not yet documented.


## [`<riff.ChunkData>.flush`](riff.ChunkData.md#riffchunkdataflush)

Not yet documented.


## [`<riff.ChunkData>.isatty`](riff.ChunkData.md#riffchunkdataisatty)

Not yet documented.


## [`<riff.ChunkData>.padded`](riff.ChunkData.md#riffchunkdatapadded)

The `padded` property of a [`riff.ChunkData`](riff.ChunkData.md#riffchunkdata) object indicates whether the chunk requires a pad byte at the end of the data block. This will be `True` if the chunk size is odd, and `False` if the chunk size is even.

```python
>>> import io
>>> stream = io.BytesIO(b'TEST\x08\x00\x00\x00TestData')
>>> import riff
{'fraction_non_alphanumeric': 0.1624628368658291, 'fraction_numerical': 0.008823247338640068, 'mean_word_length': 6.098706603131382, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 241, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6110971', 'n_tokens_mistral': 3765, 'n_tokens_neox': 3683, 'n_words': 711}