From 2996a2cd94662069782b61241caf3fe2c6288d4e Mon Sep 17 00:00:00 2001 From: mahaloz Date: Mon, 16 Sep 2024 13:23:11 -0700 Subject: [PATCH] Simplify comment wrapping --- libbs/__init__.py | 2 +- libbs/artifacts/comment.py | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/libbs/__init__.py b/libbs/__init__.py index 0a2ad7f..5e1002e 100644 --- a/libbs/__init__.py +++ b/libbs/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.22.0" +__version__ = "1.22.1" import logging diff --git a/libbs/artifacts/comment.py b/libbs/artifacts/comment.py index 3046991..0dff842 100644 --- a/libbs/artifacts/comment.py +++ b/libbs/artifacts/comment.py @@ -1,3 +1,4 @@ +import textwrap from typing import Optional from .artifact import Artifact @@ -31,22 +32,8 @@ def __str__(self): @staticmethod def linewrap_comment(comment: str, width=80): - lines = comment.splitlines() - final_comment = "" - - for line in lines: - if len(line) < width: - final_comment += line + "\n" - continue - - for i, c in enumerate(line): - if i % width == 0 and i != 0: - final_comment += "\n" - final_comment += c - - final_comment += "\n" - - return final_comment + wrapped_text = textwrap.fill(comment, width=width) + return wrapped_text def nonconflict_merge(self, obj2: "Comment", **kwargs) -> "Comment": obj1: "Comment" = self.copy()