DelfiniItemCreatorText

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

Bases: DelfiniItemCreatorCore, DelfiniItemWriterText

File-like interface for creating a new item in text 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', 'w') as fp:
    fp.write('my item content, as much as I have\n')

Attributes

buffer

closed

encoding

errors

line_buffering

mode

name

newlines

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:

str

readable()

Always False

Return type:

bool

readline(limit=-1)

N/A - cannot read

Raises:

OSError – always

Parameters:

limit (int)

Return type:

str

readlines(hint=-1)

N/A - cannot read

Raises:

OSError – always

Parameters:

hint (int)

Return type:

list[str]

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 (str) – content to write

Returns:

number of characters written

Return type:

int

writelines(lines)

Write lines to the stream.

Parameters:

lines (Iterable[str]) – iterable of lines (str) to write

Return type:

None