DelfiniItemCreatorBinary

class pydelfini.item_io.DelfiniItemCreatorBinary(collection_id, version_id, item_name, client, folder_id='ROOT', type='file', columns=None, metadata=None, parser=None, storage=None)[source]

Bases: DelfiniItemCreatorCore, DelfiniItemWriterBinary

File-like interface for creating a new item in binary mode.

It is important to either use this in a context manager or else call the close() method when writing is complete, otherwise the full contents of the file may not be written.

Suggested usage:

with collection.open('new-item', 'wb') as fp:
    fp.write(b'my item content, as much as I have\n')

Attributes

closed

mode

name

Parameters:
close()

Close and flush the stream, completing the file write.

Return type:

None

fileno()

N/A - not a real file

Raises:

OSError – always

Return type:

int

isatty()

Always False

Return type:

bool

read(n=-1)

N/A - cannot read

Raises:

OSError – always

Parameters:

n (int)

Return type:

bytes

readable()

Always False

Return type:

bool

readline(limit=-1)

N/A - cannot read

Raises:

OSError – always

Parameters:

limit (int)

Return type:

bytes

readlines(hint=-1)

N/A - cannot read

Raises:

OSError – always

Parameters:

hint (int)

Return type:

list[bytes]

seek(offset, whence=0)

N/A - not a real file

Raises:

OSError – always

Parameters:
Return type:

int

seekable()

Always False

Return type:

bool

truncate(size=None)

N/A - not a real file

Raises:

OSError – always

Parameters:

size (int | None)

Return type:

int

writable()

Always True

Return type:

bool

write(s)

Write to the stream.

Parameters:

s (bytes | Buffer) – content to write

Returns:

number of bytes written

Return type:

int

writelines(lines)

Write lines to the stream.

Parameters:

lines (Iterable[bytes] | Iterable[Buffer]) – iterable of lines (bytes or Buffer) to write

Return type:

None