freetube.settings
This commit is contained in:
parent
19153b3bc1
commit
45df475195
3 changed files with 35 additions and 2 deletions
|
@ -1 +1 @@
|
||||||
"""Handle FreeTube configuration."""
|
"""Configure FreeTube."""
|
||||||
|
|
|
@ -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.
|
||||||
|
|
33
rwx/sw/freetube/settings.py
Normal file
33
rwx/sw/freetube/settings.py
Normal 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)}\
|
||||||
|
}}\
|
||||||
|
"""
|
Loading…
Reference in a new issue