v2 refactor to label-based koans, and add discord
This commit is contained in:
19
koans/lib.py
Normal file
19
koans/lib.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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 content
|
||||
|
||||
|
||||
def utc_now():
|
||||
return datetime.now(dt.UTC)
|
||||
Reference in New Issue
Block a user