20 lines
460 B
Python
20 lines
460 B
Python
from typing import Optional
|
|
import datetime as dt
|
|
from datetime import datetime
|
|
|
|
|
|
def minify(content: str, maxlength: int, strip: Optional[str] = ' ', newlines: str = ' '):
|
|
content.replace('\n', newlines)
|
|
if strip:
|
|
content = content.strip(strip)
|
|
|
|
if len(content) > maxlength:
|
|
new_content = content[:maxlength-3] + '...'
|
|
else:
|
|
new_content = content
|
|
return new_content
|
|
|
|
|
|
def utc_now():
|
|
return datetime.now(dt.UTC)
|