class documentation

class _GitFile(object):

View In Hierarchy

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 __enter__ Undocumented
Method __exit__ Undocumented
Method __getattr__ Proxy property calls to the underlying file.
Method __init__ Undocumented
Method abort Close and discard the lockfile without overwriting the target.
Method close Close this file, saving the lockfile over the original.
Constant PROXY_METHODS Undocumented
Constant PROXY_PROPERTIES Undocumented
Instance Variable _closed Undocumented
Instance Variable _file Undocumented
Instance Variable _filename Undocumented
Instance Variable _lockfilename Undocumented
def __enter__(self):

Undocumented

def __exit__(self, exc_type, exc_val, exc_tb):

Undocumented

def __getattr__(self, name):

Proxy property calls to the underlying file.

def __init__(self, filename, mode, bufsize, mask):

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.
PROXY_METHODS: tuple[str, ...] =

Undocumented

Value
('__iter__',
 'flush',
 'fileno',
 'isatty',
 'read',
 'readline',
 'readlines',
...
PROXY_PROPERTIES =

Undocumented

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

Undocumented

_file =

Undocumented

_filename =

Undocumented

_lockfilename =

Undocumented