freetube.settings

This commit is contained in:
Marc Beninca 2024-09-23 13:27:16 +02:00
parent 19153b3bc1
commit 45df475195
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
3 changed files with 35 additions and 2 deletions

View file

@ -1 +1 @@
"""Handle FreeTube configuration.""" """Configure FreeTube."""

View file

@ -1,4 +1,4 @@
"""Handle FreeTube db.""" """Output FreeTube db."""
def to_db(value: object) -> str: def to_db(value: object) -> str:
"""Render value as string. """Render value as string.

View file

@ -0,0 +1,33 @@
"""FreeTube settings."""
from rwx import Class
from .db import to_db
class Setting(Class):
"""FreeTube setting."""
def __init__(self, uid: str, value: object) -> None:
"""Set uid & value.
:param uid: unique identifier
:type uid: str
:param value: value
:type value: object
"""
self.uid = uid
self.value = value
def to_db(self) -> str:
"""Return uid & value as db string.
:rtype: str
"""
return f"""\
{{\
"_id":"{self.uid}"\
,\
"value":{to_db(self.value)}\
}}\
"""