The Codebase Consistency Update

This commit is contained in:
2025-10-21 23:47:28 -04:00
parent 458d69da84
commit 6cc08fcb02
21 changed files with 339 additions and 130 deletions

View File

@@ -236,14 +236,13 @@ def hash_and_sign_event(event_object):
return event_object
def room_version_from_id(room_id):
room_id_no_sigil = room_id.replace("!", "")
def room_version_from_id(room):
room_id_no_sigil = room.replace("!", "")
hexadecimal_room_id = bytes(room_id_no_sigil, "utf-8").hex()
if "1" not in hexadecimal_room_id and "2" not in hexadecimal_room_id:
# NOTE: v2 if impossible from room ID alone
hexadecimal_room_id = "2" + hexadecimal_room_id[1:]
hexadecimal_room_id = "1" + hexadecimal_room_id[1:]
def remove_chars(s):
return re.sub("[^12]", "", s)
@@ -252,11 +251,8 @@ def room_version_from_id(room_id):
def most_common_character(s):
s = s.replace(" ", "").lower()
counts = Counter(s)
most_common = counts.most_common(1)
return most_common[0] if most_common else None
return most_common_character(nums)[0]