class documentation

File that follows the git locking protocol for writes.

All writes to a file foo will be written into foo.lock in the same directory, and the lockfile will be renamed to overwrite the original file on close.

Note: You must call close() or abort() on a _GitFile for the lock to be
released. Typically this will happen in a finally block.
Method __del__ Undocumented
Method __enter__ Undocumented
Method __exit__ Undocumented
Method __fspath__ Return the file path for os.fspath() compatibility.
Method __getattr__ Proxy property calls to the underlying file.
Method __init__ Undocumented
Method __iter__ Iterate over lines in the file.
Method __next__ Undocumented
Method abort Close and discard the lockfile without overwriting the target.
Method close Close this file, saving the lockfile over the original.
Method fileno Undocumented
Method flush Undocumented
Method isatty Undocumented
Method read Undocumented
Method readable Undocumented
Method readline Undocumented
Method readlines Undocumented
Method seek Undocumented
Method seekable Undocumented
Method tell Undocumented
Method truncate Undocumented
Method writable Undocumented
Method write Undocumented
Method writelines Undocumented
Constant PROXY_METHODS Undocumented
Constant PROXY_PROPERTIES Undocumented
Property closed Return whether the file is closed.
Instance Variable _closed Undocumented
Instance Variable _file Undocumented
Instance Variable _filename Undocumented
Instance Variable _fsync Undocumented
Instance Variable _lockfilename Undocumented
def __del__(self):

Undocumented

def __enter__(self) -> _GitFile:

Undocumented

def __exit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None):

Undocumented

def __fspath__(self) -> str | bytes:

Return the file path for os.fspath() compatibility.

def __getattr__(self, name: str) -> Any:

Proxy property calls to the underlying file.

def __init__(self, filename: str | bytes | os.PathLike[str] | os.PathLike[bytes], mode: str, bufsize: int, mask: int, fsync: bool = True):

Undocumented

def __iter__(self) -> Iterator[bytes]:

Iterate over lines in the file.

def __next__(self) -> bytes:

Undocumented

def abort(self):

Close and discard the lockfile without overwriting the target.

If the file is already closed, this is a no-op.

def close(self):

Close this file, saving the lockfile over the original.

Note: If this method fails, it will attempt to delete the lockfile.
However, it is not guaranteed to do so (e.g. if a filesystem becomes suddenly read-only), which will prevent future writes to this file until the lockfile is removed manually.
Raises
OSErrorif the original file could not be overwritten. The lock file is still closed, so further attempts to write to the same file object will raise ValueError.
def fileno(self) -> int:

Undocumented

def flush(self):

Undocumented

def isatty(self) -> bool:

Undocumented

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

Undocumented

def readable(self) -> bool:

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

def seekable(self) -> bool:

Undocumented

def tell(self) -> int:

Undocumented

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

Undocumented

def writable(self) -> bool:

Undocumented

def write(self, data: Buffer, /) -> int:

Undocumented

def writelines(self, lines: Iterable[Buffer], /):

Undocumented

PROXY_METHODS: ClassVar[set[str]] =

Undocumented

Value
set(['__iter__',
     '__next__',
     'flush',
     'fileno',
     'isatty',
     'read',
     'readable',
...
PROXY_PROPERTIES: ClassVar[set[str]] =

Undocumented

Value
set(['encoding', 'errors', 'mode', 'name', 'newlines', 'softspace'])
closed: bool =

Return whether the file is closed.

_closed: bool =

Undocumented

_file: IO[bytes] =

Undocumented

_filename: str | bytes =

Undocumented

_fsync =

Undocumented

_lockfilename: str | bytes =

Undocumented