class Protocol:
Known subclasses: dulwich.protocol.ReceivableProtocol
Constructor: Protocol(read, write, close, report_activity)
Class for interacting with a remote git process over the wire.
Parts of the git wire protocol use 'pkt-lines' to communicate. A pkt-line consists of the length of the line as a 4-byte hex string, followed by the payload data. The length includes the 4-byte header. The special line '0000' indicates the end of a section of input and is called a 'flush-pkt'.
- For details on the pkt-line format, see the cgit distribution:
- Documentation/technical/protocol-common.txt
| Method | __del__ |
Ensure transport is closed when Protocol is garbage collected. |
| Method | __enter__ |
Enter context manager. |
| Method | __exit__ |
Exit context manager and close transport. |
| Method | __init__ |
Initialize Protocol. |
| Method | close |
Close the underlying transport if a close function was provided. |
| Method | eof |
Test whether the protocol stream has reached EOF. |
| Method | read |
Read a command and some arguments from the git client. |
| Method | read |
Reads a pkt-line from the remote git process. |
| Method | read |
Read a sequence of pkt-lines from the remote git process. |
| Method | send |
Send a command and some arguments to a git server. |
| Method | unread |
Unread a single line of data into the readahead buffer. |
| Method | write |
Sends a pkt-line to the remote git process. |
| Method | write |
Write multiplexed data to the sideband. |
| Instance Variable | read |
Undocumented |
| Instance Variable | report |
Undocumented |
| Instance Variable | write |
Undocumented |
| Instance Variable | _close |
Undocumented |
| Instance Variable | _readahead |
Undocumented |
type[ BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None):
¶
Exit context manager and close transport.
Callable[ [ int], bytes], write: Callable[ [ bytes], int | None], close: Callable[ [], None] | None = None, report_activity: Callable[ [ int, str], None] | None = None):
¶
dulwich.protocol.ReceivableProtocolInitialize Protocol.
| Parameters | |
read:Callable[ | Function to read bytes from the transport |
write:Callable[ | Function to write bytes to the transport |
close:Callable[ | Optional function to close the transport |
reportCallable[ | Optional function to report activity |
Test whether the protocol stream has reached EOF.
Note that this refers to the actual stream EOF and not just a flush-pkt.
Returns: True if the stream is at EOF, False otherwise.
Read a command and some arguments from the git client.
Only used for the TCP git protocol (git://).
Returns: A tuple of (command, [list of arguments]).
Reads a pkt-line from the remote git process.
This method may read from the readahead buffer; see unread_pkt_line.
- Returns: The next string from the stream, without the length prefix, or
- None for a flush-pkt ('0000') or delim-pkt ('0001').
Read a sequence of pkt-lines from the remote git process.
- Returns: Yields each line of data up to but not including the next
- flush-pkt.
Unread a single line of data into the readahead buffer.
This method can be used to unread a single pkt-line into a fixed readahead buffer.
| Parameters | |
data:bytes | None | The data to unread, without the length prefix. |
| Raises | |
ValueError | If more than one pkt-line is unread. |