mirror of
https://github.com/Tech-Workers-Coalition-Italia/mobilizon-reshare.git
synced 2025-01-29 00:29:40 +01:00
Init configuration
This commit is contained in:
parent
6273e56311
commit
0d02f2dd52
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,6 +9,9 @@ __pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# Ignore dynaconf secret files
|
||||
**/.secrets.*
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
|
@ -1,4 +1 @@
|
||||
__version__ = '0.1.0'
|
||||
|
||||
|
||||
from . import publishers
|
||||
__version__ = "0.1.0"
|
||||
|
34
mobilizon_bots/config.py
Normal file
34
mobilizon_bots/config.py
Normal file
@ -0,0 +1,34 @@
|
||||
from dynaconf import Dynaconf, Validator
|
||||
|
||||
settings = Dynaconf(
|
||||
envvar_prefix="MOBOTS",
|
||||
settings_files=[
|
||||
"settings.toml",
|
||||
".secrets.toml",
|
||||
"/etc/mobots.toml",
|
||||
"/etc/mobots_secrets.toml",
|
||||
],
|
||||
validators=[
|
||||
# Ensure some parameters exists (are required)
|
||||
Validator("LOCAL_STATE_DIR", "LOG_DIR", "DB_PATH", must_exist=True),
|
||||
# Ensure some parameter mets a condition
|
||||
# conditions: (eq, ne, lt, gt, lte, gte, identity, is_type_of, is_in, is_not_in)
|
||||
Validator("LOCAL_STATE_DIR", "LOG_DIR", "DB_PATH", is_type_of=str),
|
||||
# check file or directory
|
||||
# validate a value is eq in specific env
|
||||
# Validator('PROJECT', eq='hello_world', env='production'),
|
||||
#
|
||||
# # Ensure some parameter (string) meets a condition
|
||||
# # conditions: (len_eq, len_ne, len_min, len_max, cont)
|
||||
# # Determines the minimum and maximum length for the value
|
||||
# Validator("NAME", len_min=3, len_max=125),
|
||||
#
|
||||
# # Signifies the presence of the value in a set, text or word
|
||||
# Validator("DEV_SERVERS", cont='localhost'),
|
||||
#
|
||||
# # Checks whether the length is the same as defined.
|
||||
# Validator("PORT", len_eq=4),
|
||||
],
|
||||
)
|
||||
|
||||
settings.validators.validate()
|
21
mobilizon_bots/settings.toml
Normal file
21
mobilizon_bots/settings.toml
Normal file
@ -0,0 +1,21 @@
|
||||
[default]
|
||||
DEBUG = false
|
||||
DEVELOPMENT = false
|
||||
LOCAL_STATE_DIR = "/var/mobots"
|
||||
LOG_DIR = "/var/log/mobots"
|
||||
DB_NAME = "events.db"
|
||||
DB_PATH ="@jinja /{{ this.LOCAL_STATE_DIR }}/{{ this.DB_NAME | abspath }}"
|
||||
|
||||
[development]
|
||||
DEVELOPMENT = true
|
||||
DEBUG = true
|
||||
LOCAL_STATE_DIR = "/tmp/mobots"
|
||||
LOG_DIR = "/tmp/mobots"
|
||||
DB_NAME = "development.db"
|
||||
DB_PATH="@jinja /{{ this.LOCAL_STATE_DIR }}/{{ this.DB_NAME | abspath }}"
|
||||
|
||||
[testing]
|
||||
DEBUG = true
|
||||
LOCAL_STATE_DIR = "/tmp/mobots"
|
||||
LOG_DIR = "/tmp/mobots"
|
||||
DB_PATH=":memory:"
|
Loading…
x
Reference in New Issue
Block a user