mirror of
https://github.com/tcsenpai/pensieve.git
synced 2025-06-06 19:25:24 +00:00
fix: support parse secret
This commit is contained in:
parent
f9e2b2261b
commit
6107c22def
@ -50,7 +50,7 @@ class Settings(BaseSettings):
|
|||||||
database_path: str = os.path.join(base_dir, "database.db")
|
database_path: str = os.path.join(base_dir, "database.db")
|
||||||
default_library: str = "screenshots"
|
default_library: str = "screenshots"
|
||||||
screenshots_dir: str = os.path.join(base_dir, "screenshots")
|
screenshots_dir: str = os.path.join(base_dir, "screenshots")
|
||||||
|
|
||||||
typesense_host: str = "localhost"
|
typesense_host: str = "localhost"
|
||||||
typesense_port: str = "8108"
|
typesense_port: str = "8108"
|
||||||
typesense_protocol: str = "http"
|
typesense_protocol: str = "http"
|
||||||
@ -98,6 +98,21 @@ def dict_representer(dumper, data):
|
|||||||
yaml.add_representer(OrderedDict, dict_representer)
|
yaml.add_representer(OrderedDict, dict_representer)
|
||||||
|
|
||||||
|
|
||||||
|
# Custom representer for SecretStr
|
||||||
|
def secret_str_representer(dumper, data):
|
||||||
|
return dumper.represent_scalar("tag:yaml.org,2002:str", data.get_secret_value())
|
||||||
|
|
||||||
|
|
||||||
|
# Custom constructor for SecretStr
|
||||||
|
def secret_str_constructor(loader, node):
|
||||||
|
value = loader.construct_scalar(node)
|
||||||
|
return SecretStr(value)
|
||||||
|
|
||||||
|
|
||||||
|
yaml.add_representer(SecretStr, secret_str_representer)
|
||||||
|
yaml.add_constructor("tag:yaml.org,2002:str", secret_str_constructor)
|
||||||
|
|
||||||
|
|
||||||
def create_default_config():
|
def create_default_config():
|
||||||
config_path = Path.home() / ".memos" / "config.yaml"
|
config_path = Path.home() / ".memos" / "config.yaml"
|
||||||
if not config_path.exists():
|
if not config_path.exists():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user