Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
3.1.0 : truncate() with stripping
Browse files Browse the repository at this point in the history
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
  • Loading branch information
Ari Archer committed May 9, 2023
1 parent 5462889 commit 29c20c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion awc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from . import const, exc, util

__version__: typing.Final[str] = "3.0.0"
__version__: typing.Final[str] = "3.1.0"


class Awc:
Expand Down
4 changes: 3 additions & 1 deletion awc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def truncate(content: str, length: int, do_warn: bool = True) -> str:
return str -- the truncated content"""

content = content.strip()

if do_warn and len(content) > length:
warn(ContentTruncatedWarning(content, length))

return content[:length]
return content[:length].strip()


def resp_to_bool(resp: str) -> bool:
Expand Down

0 comments on commit 29c20c8

Please sign in to comment.