Skip to content

Commit

Permalink
Update convert uuid to uuid_v2 method
Browse files Browse the repository at this point in the history
  • Loading branch information
waseem-omar committed Sep 9, 2024
1 parent 8f28c89 commit a467015
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
16 changes: 4 additions & 12 deletions native_shortuuid/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,11 @@
import shortuuid


def convert_uuid_to_uuid_v2(uuid_or_shortuuid22):
if isinstance(uuid_or_shortuuid22, uuid.UUID):
shortuuid22 = shortuuid.encode(uuid_or_shortuuid22)
else:
shortuuid22 = uuid_or_shortuuid22

if len(shortuuid22) == 22:
shortuuid20 = shortuuid22[2:]
elif len(shortuuid22) == 20:
shortuuid20 = shortuuid22
else:
raise ValueError(f'Invalid ShortUUID {shortuuid22}')
def convert_uuid_to_uuid_v2(uuid22):
if isinstance(uuid22, uuid.UUID):
uuid22 = shortuuid.encode(uuid22)

shortuuid20 = uuid22[-20:]
return shortuuid.decode(shortuuid20)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import setuptools
from setuptools.command.install import install

VERSION = "1.4.9"
VERSION = "1.4.10"


def readme():
Expand Down

0 comments on commit a467015

Please sign in to comment.