-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hive-common: Add hive.common.parse_uuid
- Loading branch information
Showing
4 changed files
with
20 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .argument_parser import HiveArgumentParser as ArgumentParser | ||
from .config import read as read_config | ||
from .resource import read_resource | ||
from .uuid import parse_uuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from uuid import RFC_4122, UUID | ||
|
||
|
||
def parse_uuid(uuid: str | UUID) -> UUID: | ||
if not isinstance(uuid, UUID): | ||
uuid = UUID(uuid) | ||
|
||
if uuid.variant != RFC_4122: | ||
raise ValueError(uuid) | ||
if uuid.version != 4: | ||
raise ValueError(uuid) | ||
|
||
return uuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters