-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.py
More file actions
55 lines (47 loc) · 1.36 KB
/
config.py
File metadata and controls
55 lines (47 loc) · 1.36 KB
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
import os
import re
def sitename_from_readme():
"""
Return text after hash on first non-blank line, if found, otherwise None.
"""
with open('README.md') as f:
for line in f:
if not line.strip():
continue
m = re.match('#(.*)$', line)
return m.group(1).strip() if m else None
def splitcamel(s):
"""
Split string s into CamelCase parts.
"""
r = re.findall('[A-Z][^A-Z]+', s)
if r:
return r
else:
return [s]
class Config(object):
# configuration
NAME = "DEBUG"
SECRET_KEY = os.environ.get("SECRET_KEY")
DEBUG = True
MAIL_SERVER = "smtp.gmail.com"
MAIL_USERNAME = "KentonCountyLibrary@gmail.com"
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD",None)
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_DEFAULT_SENDER = "KentonCountyLibrary@gmail.com"
SQLALCHEMY_DATABASE_URI = "sqlite:///library.db"
SITENAME = sitename_from_readme()
if not SITENAME:
raise RuntimeError("The site's name not found in README.")
SITENAMEPARTS = splitcamel(SITENAME)
def __init__(self):
print "Config environment is: " + self.NAME
class TestConfig(Config):
NAME = "TEST"
SQLALCHEMY_DATABASE_URI = "sqlite://"
config = None
if os.environ.get("LIBRARY_ENV",None) == "test":
config = TestConfig()
else:
config = Config()