freetube.db

This commit is contained in:
Marc Beninca 2024-09-23 13:04:56 +02:00
parent e61be6cf4f
commit 19153b3bc1
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

20
rwx/sw/freetube/db.py Normal file
View file

@ -0,0 +1,20 @@
"""Handle FreeTube db."""
def to_db(value: object) -> str:
"""Render value as string.
:param value: value to render
:type value: object
:rtype: str
"""
match value:
case bool():
text = str(value).lower()
case dict():
sub = ",".join([f'"{i}":{to_db(v)}' for i, v in value.items()])
text = f"{{{sub}}}"
case float() | str():
text = f'"{value}"'
case _:
text = str(value)
return text