freetube.db
This commit is contained in:
parent
e61be6cf4f
commit
19153b3bc1
1 changed files with 20 additions and 0 deletions
20
rwx/sw/freetube/db.py
Normal file
20
rwx/sw/freetube/db.py
Normal 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
|
Loading…
Reference in a new issue