class ShaFile:
Known subclasses: dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.Tree
Constructors: ShaFile.from_file(f, sha, object_format), ShaFile.from_path(path, sha, object_format), ShaFile.from_string(string), ShaFile.from_raw_chunks(type_num, chunks, sha), ShaFile.from_raw_string(type_num, string, sha, object_format), ShaFile(), ShaFile._parse_file(f, object_format), ShaFile._parse_legacy_object_header(magic, f), ShaFile._parse_object_header(magic, f)
A git SHA file.
| Class Method | from |
Get the contents of a SHA file on disk. |
| Class Method | from |
Open a SHA file from disk. |
| Class Method | from |
Create a ShaFile from a string. |
| Static Method | from |
Creates an object of the indicated type from the raw chunks given. |
| Static Method | from |
Creates an object of the indicated type from the raw string given. |
| Method | __bytes__ |
Return raw string serialization of this object. |
| Method | __eq__ |
Return True if the SHAs of the two objects match. |
| Method | __hash__ |
Return unique hash for this object. |
| Method | __init__ |
Initialize a ShaFile. |
| Method | __le__ |
Check whether SHA of this object is less than or equal to the other. |
| Method | __lt__ |
Return whether SHA of this object is less than the other. |
| Method | __ne__ |
Check whether this object does not match the other. |
| Method | __repr__ |
Return string representation of this object. |
| Method | as |
Return string representing the object in the experimental format. |
| Method | as |
Return chunks representing the object in the experimental format. |
| Method | as |
Return a string representing this object, fit for display. |
| Method | as |
Return chunks with serialization of the object. |
| Method | as |
Return raw string with serialization of the object. |
| Method | check |
Check this object for internal consistency. |
| Method | copy |
Create a new copy of this SHA1 object from its raw string. |
| Method | get |
Get the hex SHA of this object using the specified hash algorithm. |
| Method | raw |
Returns the length of the raw string of this object. |
| Method | set |
Set the contents of this object from a list of chunks. |
| Method | set |
Set the contents of this object from a serialized string. |
| Method | sha |
The SHA object that is the name of this object. |
| Class Variable | __slots__ |
Undocumented |
| Class Variable | type |
Undocumented |
| Class Variable | type |
Undocumented |
| Instance Variable | object |
Undocumented |
| Property | id |
The hex SHA1 of this object. |
| Class Method | _is |
Undocumented |
| Class Method | _parse |
Undocumented |
| Static Method | _parse |
Parse a legacy object, creating it but not reading the file. |
| Static Method | _parse |
Parse a new style object, creating it but not reading the file. |
| Method | _check |
Check that the object has a given member variable. |
| Method | _deserialize |
Undocumented |
| Method | _header |
Undocumented |
| Method | _parse |
Parse a legacy object, setting the raw string. |
| Method | _parse |
Parse a new style object, setting self._text. |
| Method | _serialize |
Undocumented |
| Instance Variable | _chunked |
Undocumented |
| Instance Variable | _needs |
Undocumented |
| Instance Variable | _sha |
Undocumented |
BufferedIOBase | IO[ bytes] | _GitFile, sha: ObjectID | None = None, *, object_format: ObjectFormat | None = None) -> ShaFile:
¶
Get the contents of a SHA file on disk.
str | bytes, sha: ObjectID | None = None, *, object_format: ObjectFormat | None = None) -> ShaFile:
¶
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeOpen a SHA file from disk.
int, string: bytes, sha: ObjectID | RawObjectID | None = None, *, object_format: ObjectFormat | None = None) -> ShaFile:
¶
Creates an object of the indicated type from the raw string given.
| Parameters | |
typeint | The numeric type of the object. |
string:bytes | The raw uncompressed contents. |
sha:ObjectID | RawObjectID | None | Optional known sha for the object |
objectObjectFormat | None | Optional hash algorithm for the object |
| Returns | |
ShaFile | Undocumented |
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeInitialize a ShaFile.
Return chunks with serialization of the object.
Returns: List of strings, not necessarily one per line
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeCheck this object for internal consistency.
| Raises | |
ObjectFormatException | if the object is malformed in some way |
ChecksumMismatch | if the object was created with a SHA that does not match its contents |
Get the hex SHA of this object using the specified hash algorithm.
Example
>>> blob = Blob() >>> blob.data = b"Hello, World!" >>> blob.id # Always returns SHA1 for backward compatibility b'4ab299c8ad6ed14f31923dd94f8b5f5cb89dfb54' >>> blob.get_id() # Same as .id b'4ab299c8ad6ed14f31923dd94f8b5f5cb89dfb54' >>> from dulwich.object_format import SHA256 >>> blob.get_id(SHA256) # Get SHA256 hash b'03ba204e2f2e707...' # 64-character SHA256
| Parameters | |
objectObjectFormat | None | Optional HashAlgorithm to use. Defaults to SHA1. |
| Returns | |
bytes | Undocumented |
list[ bytes], sha: ObjectID | RawObjectID | None = None, *, object_format: ObjectFormat | None = None):
¶
Set the contents of this object from a list of chunks.
The SHA object that is the name of this object.
| Parameters | |
objectObjectFormat | None | Optional HashAlgorithm to use. Defaults to SHA1. |
| Returns | |
FixedSha | HASH | Undocumented |
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeUndocumented
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeUndocumented
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeUndocumented
The hex SHA1 of this object.
For SHA256 repositories, use get_id(object_format) instead. This property always returns SHA1 for backward compatibility.
BufferedIOBase | IO[ bytes] | _GitFile, *, object_format: ObjectFormat | None = None) -> ShaFile:
¶
Undocumented
bytes, f: BufferedIOBase | IO[ bytes] | _GitFile) -> ShaFile:
¶
Parse a legacy object, creating it but not reading the file.
Parse a new style object, creating it but not reading the file.
Check that the object has a given member variable.
| Parameters | |
member:str | the member variable to check for |
errorstr | the message for an error if the member is missing |
| Raises | |
ObjectFormatException | with the given error_msg if member is missing or is None |
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeUndocumented
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeUndocumented
dulwich.objects.Blob, dulwich.objects.Commit, dulwich.objects.Tag, dulwich.objects.TreeUndocumented