Changeset View
Changeset View
Standalone View
Standalone View
swh/model/git_objects.py
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | if content.data is None: | ||||
raise model.MissingData("Content data is None, cannot format.") | raise model.MissingData("Content data is None, cannot format.") | ||||
return git_object_header("blob", len(content.data)) + content.data | return git_object_header("blob", len(content.data)) + content.data | ||||
def directory_entry_sort_key(entry: model.DirectoryEntry): | def directory_entry_sort_key(entry: model.DirectoryEntry): | ||||
"""The sorting key for tree entries""" | """The sorting key for tree entries""" | ||||
if isinstance(entry, dict): | if isinstance(entry, dict): | ||||
# For backward compatibility | type_ = entry["type"] | ||||
entry = model.DirectoryEntry.from_dict(entry) | name = entry["name"] | ||||
if entry.type == "dir": | else: | ||||
return entry.name + b"/" | type_ = entry.type | ||||
name = entry.name | |||||
if type_ == "dir": | |||||
return name + b"/" | |||||
else: | else: | ||||
return entry.name | return name | ||||
@lru_cache() | @lru_cache() | ||||
def _perms_to_bytes(perms): | def _perms_to_bytes(perms): | ||||
"""Convert the perms value to its canonical bytes representation""" | """Convert the perms value to its canonical bytes representation""" | ||||
oc = oct(perms)[2:] | oc = oct(perms)[2:] | ||||
return oc.encode("ascii") | return oc.encode("ascii") | ||||
▲ Show 20 Lines • Show All 583 Lines • Show Last 20 Lines |