InputStream Class

Inheritance
azure.functions._abc.InputStream
InputStream

Constructor

InputStream(*, data: bytes | Datum, name: str | None = None, uri: str | None = None, length: int | None = None)

Keyword-Only Parameters

Name Description
data
Required
name
Required
uri
Required
length
Required

Methods

close

Flush and close the IO object.

This method has no effect if the file is already closed.

detach

Disconnect this buffer from its underlying raw stream and return it.

After the raw stream has been detached, the buffer is in an unusable state.

fileno

Returns underlying file descriptor if one exists.

OSError is raised if the IO object does not use a file descriptor.

flush

Flush write buffers, if applicable.

This is not implemented for read-only and non-blocking streams.

isatty

Return whether this is an 'interactive' stream.

Return False if it can't be determined.

read
read1

Read and return up to n bytes, with at most one read() call to the underlying raw stream. A short result does not imply that EOF is imminent.

Returns an empty bytes object on EOF.

readable
readinto
readinto1
readline

Read and return a line from the stream.

If size is specified, at most size bytes will be read.

The line terminator is always b'n' for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.

readlines

Return a list of lines from the stream.

hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.

seek

Change the stream position to the given byte offset.

offset The stream position, relative to 'whence'.

whence The relative position to seek from.

The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • os.SEEK_SET or 0 – start of stream (the default); offset should be zero or positive

  • os.SEEK_CUR or 1 – current stream position; offset may be negative

  • os.SEEK_END or 2 – end of stream; offset is usually negative

Return the new absolute position.

seekable
tell

Return current stream position.

truncate

Truncate file to size bytes.

File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.

writable
write

Write the given buffer to the IO stream.

Returns the number of bytes written, which is always the length of b in bytes.

Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment.

writelines

Write a list of lines to stream.

Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.

close

Flush and close the IO object.

This method has no effect if the file is already closed.

close()

detach

Disconnect this buffer from its underlying raw stream and return it.

After the raw stream has been detached, the buffer is in an unusable state.

detach()

fileno

Returns underlying file descriptor if one exists.

OSError is raised if the IO object does not use a file descriptor.

fileno()

flush

Flush write buffers, if applicable.

This is not implemented for read-only and non-blocking streams.

flush()

isatty

Return whether this is an 'interactive' stream.

Return False if it can't be determined.

isatty()

read

read(size=-1) -> bytes

Parameters

Name Description
size
default value: -1

read1

Read and return up to n bytes, with at most one read() call to the underlying raw stream. A short result does not imply that EOF is imminent.

Returns an empty bytes object on EOF.

read1()

readable

readable() -> bool

readinto

readinto(buffer, /)

Positional-Only Parameters

Name Description
buffer
Required

readinto1

readinto1(buffer, /)

Positional-Only Parameters

Name Description
buffer
Required

readline

Read and return a line from the stream.

If size is specified, at most size bytes will be read.

The line terminator is always b'n' for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.

readline(size=-1, /)

Positional-Only Parameters

Name Description
size
default value: -1

readlines

Return a list of lines from the stream.

hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.

readlines(hint=-1, /)

Positional-Only Parameters

Name Description
hint
default value: -1

seek

Change the stream position to the given byte offset.

offset The stream position, relative to 'whence'.

whence The relative position to seek from.

The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • os.SEEK_SET or 0 – start of stream (the default); offset should be zero or positive

  • os.SEEK_CUR or 1 – current stream position; offset may be negative

  • os.SEEK_END or 2 – end of stream; offset is usually negative

Return the new absolute position.

seek(offset, whence=0, /)

Positional-Only Parameters

Name Description
offset
Required
whence
default value: 0

seekable

seekable() -> bool

tell

Return current stream position.

tell()

truncate

Truncate file to size bytes.

File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.

truncate()

writable

writable() -> bool

write

Write the given buffer to the IO stream.

Returns the number of bytes written, which is always the length of b in bytes.

Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment.

write()

writelines

Write a list of lines to stream.

Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.

writelines(lines, /)

Positional-Only Parameters

Name Description
lines
Required

Attributes

closed

length

name

uri