-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
99 lines (84 loc) · 3.95 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import os
from dotenv import load_dotenv
import app.src.common as Common
# Get base working directory and load env variables
basedir = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(basedir, ".env"))
class Config(object):
"""Class to load all config parameters of the Flask App"""
DEFAULT_ADMIN_USERNAME = os.environ.get("DEFAULT_ADMIN_USERNAME") or "admin"
DEFAULT_ADMIN_EMAIL = os.environ.get("DEFAULT_ADMIN_EMAIL") or "[email protected]"
DEFAULT_ADMIN_PASSWORD = os.environ.get("DEFAULT_ADMIN_PASSWORD") or "admin"
SECRET_KEY = os.environ.get("SECRET_KEY") or "myverylongsecretkey"
DATA_FOLDER = os.path.join(basedir, "data")
ONTOLOGY_FOLDER = os.path.join(basedir, "data", "ontology")
IMAGES_FOLDER = os.path.join(basedir, "data", "images")
CONFIG_FOLDER = os.path.join(basedir, "config")
VIZ_FOLDER = os.path.join(basedir, "app", "static", "viz")
negex_en = open(os.path.join(CONFIG_FOLDER, "negex_en.txt"), "r")
negex_fr = open(os.path.join(CONFIG_FOLDER, "negex_fr.txt"), "r")
NEGEX_LIST_EN = [line.strip("\n") for line in negex_en.readlines()]
NEGEX_LIST_FR = [line.strip("\n") for line in negex_fr.readlines()]
negex_sent_en = open(os.path.join(CONFIG_FOLDER, "negex_sep_en.txt"), "r")
negex_sent_fr = open(os.path.join(CONFIG_FOLDER, "negex_sep_fr.txt"), "r")
NEGEX_SENT_EN = [line.strip("\n") for line in negex_sent_en.readlines()]
NEGEX_SENT_FR = [line.strip("\n") for line in negex_sent_fr.readlines()]
SEND_FILE_MAX_AGE_DEFAULT = 0
SESSION_COOKIE_SAMESITE = "Lax"
SESSION_COOKIE_SECURE = "True"
# Session saving on filesystem instead of user cookie
SESSION_TYPE = "filesystem"
# Max upload size: 1GB
MAX_CONTENT_LENGTH = 1024 * 1024 * 1024
# DB connection settings
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(
basedir, "data", "database", "app.db"
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Mail Settings from environnement variables
MAIL_SERVER = os.environ.get("MAIL_SERVER")
MAIL_PORT = int(os.environ.get("MAIL_PORT") or 25)
MAIL_USE_TLS = os.environ.get("MAIL_USE_TLS") is not None
MAIL_USERNAME = os.environ.get("MAIL_USERNAME")
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD")
ADMINS_EMAIL = [os.environ.get("ADMINS_EMAIL")]
# Heroku to STDOut
LOG_TO_STDOUT = os.environ.get("LOG_TO_STDOUT")
ONTO_SCHEMA = {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {"type": "string", "pattern": "^.*[:|_].*$"},
"text": {"type": "string"},
"icon": {"type": "boolean"},
"data": {
"type": "object",
"properties": {
"description": {"type": "string"},
"synonymes": {"type": "string"},
"phenotype_datamined": {"type": "string"},
"gene_datamined": {"type": "string"},
"alternative_language": {"type": "string"},
"correlates_with": {"type": "string"},
"image_annotation": {"type": "boolean"},
"hex_color": {"type": "string", "pattern": "^#[0-9a-fA-F]{6}$"},
"hpo_datamined": {"type": "string"},
},
"required": [
"description",
"synonymes",
"phenotype_datamined",
"gene_datamined",
"alternative_language",
"correlates_with",
"image_annotation",
"hex_color",
"hpo_datamined",
],
},
"parent": {"type": "string", "pattern": "[^.*[:|_].*$|^#$]]"},
},
"required": ["id", "text", "icon", "data", "parent"],
},
}