From 0f05f120b6157e649eb5e9c94d049e99a1eb29f1 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Thu, 25 Apr 2024 12:58:42 -0400 Subject: [PATCH] version --- dcicutils/file_utils.py | 12 +++++++----- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dcicutils/file_utils.py b/dcicutils/file_utils.py index eb865fd64..89c4af368 100644 --- a/dcicutils/file_utils.py +++ b/dcicutils/file_utils.py @@ -103,7 +103,7 @@ def are_files_equal(filea: str, fileb: str) -> bool: def create_random_file(file: Optional[str] = None, prefix: Optional[str] = None, suffix: Optional[str] = None, - nbytes: int = 1024, binary: bool = False) -> str: + nbytes: int = 1024, binary: bool = False, line_length: Optional[int] = None) -> str: if not isinstance(nbytes, int) or nbytes < 0: nbytes = 0 if not isinstance(file, str) or not file: @@ -116,11 +116,13 @@ def create_random_file(file: Optional[str] = None, if binary is True: f.write(os.urandom(nbytes)) else: - nchars = 81 - nlines = nbytes // nchars - nremainder = nbytes % nchars + if (not isinstance(line_length, int)) or (line_length < 1): + line_length = 80 + line_length += 1 + nlines = nbytes // line_length + nremainder = nbytes % line_length for n in range(nlines): - f.write("".join(random.choices(string.ascii_letters + string.digits, k=nchars - 1))) + f.write("".join(random.choices(string.ascii_letters + string.digits, k=line_length - 1))) f.write("\n") if nremainder > 1: f.write("".join(random.choices(string.ascii_letters + string.digits, k=nremainder - 1))) diff --git a/pyproject.toml b/pyproject.toml index b335f35d0..4e4617f0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.8.4.1b10" # TODO: To become 8.8.5 +version = "8.8.4.1b11" # TODO: To become 8.8.5 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT"