fix loading of config file
This commit is contained in:
parent
bd9fcd1edc
commit
6f589b86e2
@ -16,23 +16,6 @@ PREFIXES = [
|
|||||||
"CARGO",
|
"CARGO",
|
||||||
]
|
]
|
||||||
|
|
||||||
def _get_var(key: str, fallback: str) -> List[str]:
|
|
||||||
value = os.environ.get(
|
|
||||||
PREFIXES[0] + "_" + key,
|
|
||||||
os.environ.get(
|
|
||||||
key,
|
|
||||||
None
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if value is None:
|
|
||||||
for prefix in PREFIXES[1:]:
|
|
||||||
value = os.environ.get(prefix + "_" + key, None)
|
|
||||||
if value != None:
|
|
||||||
break
|
|
||||||
|
|
||||||
return (value or fallback).split("/")
|
|
||||||
|
|
||||||
|
|
||||||
# env key is just a backup key for compatibility with cargo mommy
|
# env key is just a backup key for compatibility with cargo mommy
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
@ -48,12 +31,10 @@ CONFIG = {
|
|||||||
"role": {
|
"role": {
|
||||||
"defaults": ["mommy"]
|
"defaults": ["mommy"]
|
||||||
},
|
},
|
||||||
|
|
||||||
"affectionate_term": {
|
"affectionate_term": {
|
||||||
"defaults": ["girl"],
|
"defaults": ["girl"],
|
||||||
"env_key": "LITTLE"
|
"env_key": "LITTLE"
|
||||||
},
|
},
|
||||||
|
|
||||||
"denigrating_term": {
|
"denigrating_term": {
|
||||||
"spiciness": "yikes",
|
"spiciness": "yikes",
|
||||||
"defaults": ["slut", "toy", "pet", "pervert", "whore"],
|
"defaults": ["slut", "toy", "pet", "pervert", "whore"],
|
||||||
@ -154,9 +135,9 @@ def load_config_file(config_file: Path) -> bool:
|
|||||||
|
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
CONFIG[key]["default"] = [value]
|
CONFIG[key]["defaults"] = [value]
|
||||||
else:
|
else:
|
||||||
CONFIG[key]["default"] = value
|
CONFIG[key]["defaults"] = value
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -196,4 +177,4 @@ def get_template_values(mood: str) -> Dict[str, str]:
|
|||||||
|
|
||||||
result[key] = random.choice(value["defaults"])
|
result[key] = random.choice(value["defaults"])
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user