This commit is contained in:
Yax 2018-09-15 13:38:03 +02:00
parent ed2a284102
commit 0a2cdbbe8f
17 changed files with 197 additions and 272 deletions

View file

@ -1,3 +1,48 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import profig
# constants
FLASK_APP = "flask.app"
DB_URL = "main.db_url"
HTTP_HOST = "http.host"
HTTP_PORT = "http.port"
SECURITY_SALT = "security.salt"
SECURITY_SECRET = "security.secret"
MAIL_POLLING = "polling.newmail"
COMMENT_POLLING = "polling.newcomment"
# variable
params = dict()
def initialize(config_pathname, flask_app):
cfg = profig.Config(config_pathname)
cfg.sync()
params.update(cfg)
params.update({FLASK_APP: flask_app})
def get(key):
return params[key]
def getInt(key):
return int(params[key])
def _str2bool(v):
return v.lower() in ("yes", "true", "t", "1")
def getBool(key):
return _str2bool(params[key])
def flaskapp():
return params[FLASK_APP]

View file

@ -1,115 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created with https://app.quicktype.io
# name: stacosys
json_schema = """
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/Welcome",
"definitions": {
"Welcome": {
"type": "object",
"additionalProperties": false,
"properties": {
"general": {
"$ref": "#/definitions/General"
},
"http": {
"$ref": "#/definitions/HTTP"
},
"security": {
"$ref": "#/definitions/Security"
},
"rss": {
"$ref": "#/definitions/RSS"
}
},
"required": [
"general",
"http",
"rss",
"security"
],
"title": "Welcome"
},
"General": {
"type": "object",
"additionalProperties": false,
"properties": {
"debug": {
"type": "boolean"
},
"lang": {
"type": "string"
},
"db_url": {
"type": "string"
}
},
"required": [
"db_url",
"debug",
"lang"
],
"title": "General"
},
"HTTP": {
"type": "object",
"additionalProperties": false,
"properties": {
"root_url": {
"type": "string"
},
"host": {
"type": "string"
},
"port": {
"type": "integer"
}
},
"required": [
"host",
"port",
"root_url"
],
"title": "HTTP"
},
"RSS": {
"type": "object",
"additionalProperties": false,
"properties": {
"proto": {
"type": "string"
},
"file": {
"type": "string"
}
},
"required": [
"file",
"proto"
],
"title": "RSS"
},
"Security": {
"type": "object",
"additionalProperties": false,
"properties": {
"salt": {
"type": "string"
},
"secret": {
"type": "string"
}
},
"required": [
"salt",
"secret"
],
"title": "Security"
}
}
}
"""