diff --git a/rwx/sw/freetube/__init__.py b/rwx/sw/freetube/__init__.py index cb60ff9..250b9c3 100644 --- a/rwx/sw/freetube/__init__.py +++ b/rwx/sw/freetube/__init__.py @@ -1 +1 @@ -"""Handle FreeTube configuration.""" +"""Configure FreeTube.""" diff --git a/rwx/sw/freetube/db.py b/rwx/sw/freetube/db.py index 4b3f56b..9e37162 100644 --- a/rwx/sw/freetube/db.py +++ b/rwx/sw/freetube/db.py @@ -1,4 +1,4 @@ -"""Handle FreeTube db.""" +"""Output FreeTube db.""" def to_db(value: object) -> str: """Render value as string. diff --git a/rwx/sw/freetube/settings.py b/rwx/sw/freetube/settings.py new file mode 100644 index 0000000..67bb084 --- /dev/null +++ b/rwx/sw/freetube/settings.py @@ -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)}\ +}}\ +"""