class documentation

class SHA1Writer(BinaryIO):

Constructor: SHA1Writer(f)

View In Hierarchy

Wrapper for file-like object that remembers the SHA1 of its data.

Method __enter__ Enter context manager.
Method __exit__ Exit context manager and close file.
Method __init__ Initialize SHA1Writer.
Method __iter__ Return iterator.
Method __next__ Not supported for write-only file.
Method close Close the pack file and finalize the SHA.
Method fileno Return file descriptor number.
Method flush Flush the file buffer.
Method isatty Check if file is a terminal.
Method offset Get the total number of bytes written.
Method read Not supported for write-only file.
Method readable Check if file is readable.
Method readline Not supported for write-only file.
Method readlines Not supported for write-only file.
Method seek Seek to position in file.
Method seekable Check if file is seekable.
Method tell Return current file position.
Method truncate Not supported for write-only file.
Method writable Check if file is writable.
Method write Write data and update SHA1.
Method write_sha Write the SHA1 digest to the file.
Method writelines Write multiple lines to the file.
Instance Variable digest Undocumented
Instance Variable f Undocumented
Instance Variable length Undocumented
Instance Variable sha1 Undocumented
def __enter__(self) -> SHA1Writer:

Enter context manager.

def __exit__(self, type: type | None, value: BaseException | None, traceback: TracebackType | None):

Exit context manager and close file.

def __init__(self, f: BinaryIO | IO[bytes]):

Initialize SHA1Writer.

Parameters
f:BinaryIO | IO[bytes]File-like object to wrap
def __iter__(self) -> SHA1Writer:

Return iterator.

def __next__(self) -> bytes:

Not supported for write-only file.

Raises
UnsupportedOperationAlways raised
def close(self):

Close the pack file and finalize the SHA.

def fileno(self) -> int:

Return file descriptor number.

def flush(self):

Flush the file buffer.

def isatty(self) -> bool:

Check if file is a terminal.

def offset(self) -> int:

Get the total number of bytes written.

Returns
intTotal bytes written
def read(self, size: int = -1) -> bytes:

Not supported for write-only file.

Raises
UnsupportedOperationAlways raised
def readable(self) -> bool:

Check if file is readable.

def readline(self, size: int = -1) -> bytes:

Not supported for write-only file.

Raises
UnsupportedOperationAlways raised
def readlines(self, hint: int = -1) -> list[bytes]:

Not supported for write-only file.

Raises
UnsupportedOperationAlways raised
def seek(self, offset: int, whence: int = 0) -> int:

Seek to position in file.

Parameters
offset:intPosition offset
whence:intReference point (0=start, 1=current, 2=end)
Returns
intNew file position
def seekable(self) -> bool:

Check if file is seekable.

def tell(self) -> int:

Return current file position.

def truncate(self, size: int | None = None) -> int:

Not supported for write-only file.

Raises
UnsupportedOperationAlways raised
def writable(self) -> bool:

Check if file is writable.

def write(self, data: bytes | bytearray | memoryview, /) -> int:

Write data and update SHA1.

Parameters
data:bytes | bytearray | memoryviewData to write
Returns
intNumber of bytes written
def write_sha(self) -> bytes:

Write the SHA1 digest to the file.

Returns
bytesThe SHA1 digest bytes
def writelines(self, lines: Iterable[bytes], /):

Write multiple lines to the file.

Parameters
lines:Iterable[bytes]Iterable of lines to write
digest: bytes | None =

Undocumented

f =

Undocumented

length: int =

Undocumented

sha1 =

Undocumented