Add record keys support.

Changed files
+49
src
atpasser
recordKeys
+49
src/atpasser/recordKeys/__init__.py
···
···
+
class RecordKey:
+
"""
+
A class representing a RecordKey.
+
+
+
Attributes:
+
recordKey (str): The RecordKey URI.
+
"""
+
+
def __init__(self, recordKey: str) -> None:
+
"""
+
Initalizes an RecordKey object.
+
+
Parameters:
+
recordKey (str): The RecordKey.
+
"""
+
+
if recordKey == "" or len(recordKey) > 512:
+
raise ValueError("null record key or record key longer than 512 chars")
+
+
if recordKey == ".." or recordKey == ".":
+
raise ValueError("reserved value . and ..")
+
+
if not set(recordKey).issubset(
+
set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_:~")
+
):
+
raise ValueError("invalid char")
+
+
self.recordKey = recordKey
+
+
def __str__(self) -> str:
+
"""
+
+
Convert the RecordKey to a string by given the URI.
+
"""
+
return self.recordKey
+
+
def __eq__(self, value: object, /) -> bool:
+
"""
+
+
Check if the 2 values are exactly the same.
+
"""
+
+
if isinstance(value, RecordKey):
+
+
return str(self) == str(value)
+
else:
+
+
raise TypeError