summaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/fcid.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/fatcat_tools/fcid.py')
-rw-r--r--python/fatcat_tools/fcid.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/python/fatcat_tools/fcid.py b/python/fatcat_tools/fcid.py
index 53891e5a..07463f62 100644
--- a/python/fatcat_tools/fcid.py
+++ b/python/fatcat_tools/fcid.py
@@ -2,17 +2,17 @@ import base64
import uuid
-def fcid2uuid(s):
+def fcid2uuid(fcid: str) -> str:
"""
Converts a fatcat identifier (base32 encoded string) to a uuid.UUID object
"""
- s = s.split("_")[-1].upper().encode("utf-8")
- assert len(s) == 26
- raw = base64.b32decode(s + b"======")
- return str(uuid.UUID(bytes=raw)).lower()
+ b = fcid.split("_")[-1].upper().encode("utf-8")
+ assert len(b) == 26
+ raw_bytes = base64.b32decode(b + b"======")
+ return str(uuid.UUID(bytes=raw_bytes)).lower()
-def uuid2fcid(s):
+def uuid2fcid(s: str) -> str:
"""
Converts a uuid.UUID object to a fatcat identifier (base32 encoded string)
"""
@@ -20,6 +20,6 @@ def uuid2fcid(s):
return base64.b32encode(raw)[:26].lower().decode("utf-8")
-def test_fcid():
+def test_fcid() -> None:
test_uuid = "00000000-0000-0000-3333-000000000001"
assert test_uuid == fcid2uuid(uuid2fcid(test_uuid))