From 31d1a6a713d177990609767d508209ced19ca396 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 2 Nov 2021 18:14:59 -0700 Subject: fmt (black): fatcat_tools/ --- python/fatcat_tools/fcid.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'python/fatcat_tools/fcid.py') diff --git a/python/fatcat_tools/fcid.py b/python/fatcat_tools/fcid.py index 0987d10d..53891e5a 100644 --- a/python/fatcat_tools/fcid.py +++ b/python/fatcat_tools/fcid.py @@ -1,4 +1,3 @@ - import base64 import uuid @@ -7,18 +6,20 @@ def fcid2uuid(s): """ Converts a fatcat identifier (base32 encoded string) to a uuid.UUID object """ - s = s.split('_')[-1].upper().encode('utf-8') + s = s.split("_")[-1].upper().encode("utf-8") assert len(s) == 26 raw = base64.b32decode(s + b"======") return str(uuid.UUID(bytes=raw)).lower() + def uuid2fcid(s): """ Converts a uuid.UUID object to a fatcat identifier (base32 encoded string) """ raw = uuid.UUID(s).bytes - return base64.b32encode(raw)[:26].lower().decode('utf-8') + return base64.b32encode(raw)[:26].lower().decode("utf-8") + def test_fcid(): - test_uuid = '00000000-0000-0000-3333-000000000001' + test_uuid = "00000000-0000-0000-3333-000000000001" assert test_uuid == fcid2uuid(uuid2fcid(test_uuid)) -- cgit v1.2.3