Skip to content

Commit

Permalink
added create_uuid to misc_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed May 6, 2024
1 parent 59a71d7 commit 33e1edf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions dcicutils/misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2714,7 +2714,20 @@ def get_cpu_architecture_name() -> str:
return ""


def short_uuid(length: Optional[int] = None):
def create_uuid(nodash: bool = False, upper: bool = False) -> str:
value = str(uuid.uuid4())
if nodash is True:
value = value.replace("-", "")
if upper is True:
value = value.upper()
return value


def create_short_uuid(length: Optional[int] = None, upper: bool = False):
# Not really techincally a uuid of course.
if (length is None) or (not isinstance(length, int)) or (length < 1):
length = 16
return shortuuid.ShortUUID().random(length=length)
value = shortuuid.ShortUUID().random(length=length)
if upper is True:
value = value.upper()
return value
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "8.8.4.1b21" # TODO: To become 8.8.5
version = "8.8.4.1b22" # TODO: To become 8.8.5
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
license = "MIT"
Expand Down

0 comments on commit 33e1edf

Please sign in to comment.