33 lines
582 B
Python
33 lines
582 B
Python
"""FreeTube settings."""
|
|
|
|
from rwx import Object
|
|
|
|
from .db import to_db
|
|
|
|
|
|
class Setting(Object):
|
|
"""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)}\
|
|
}}\
|
|
"""
|