|
1 | 1 | """
|
2 | 2 | Global configuration of the project.
|
3 |
| -All hardcoded paths should be (theoretically) here. |
| 3 | +All hardcoded pathes and other data should be |
| 4 | +(theoretically) here. |
4 | 5 | """
|
5 | 6 | from __future__ import print_function
|
6 | 7 |
|
7 | 8 | import logging
|
8 | 9 | import os
|
| 10 | +import yaml |
9 | 11 | from pygments.styles import get_all_styles
|
10 | 12 |
|
11 | 13 | USE_OS_PACKAGES = True # set to False if you pull cheat sheets repositories from GitHub
|
12 | 14 | DOCKERIZED = False # set to True if the service is running in a Docker container
|
13 | 15 |
|
| 16 | +SERVER_ADDRESS = '0.0.0.0' |
| 17 | +SERVER_PORT = 8002 |
| 18 | + |
14 | 19 | MYDIR = os.path.abspath(os.path.join(__file__, '..', '..'))
|
| 20 | +_CONF_FILE = os.path.join(MYDIR, 'etc/config.yaml') |
15 | 21 |
|
16 | 22 | if DOCKERIZED:
|
17 | 23 | REDISHOST = 'redis'
|
|
39 | 45 | PATH_CHEAT_SHEETS_SPOOL = os.path.join(MYDIR, "cheatsheets/spool/")
|
40 | 46 | PATH_LEARNXINY = os.path.join(MYDIR, "cheatsheets/learnxinyminutes-docs")
|
41 | 47 |
|
| 48 | +# |
| 49 | +# Reading configuration from etc/config.yaml |
| 50 | +# config overrides default settings |
| 51 | +# |
| 52 | +if os.path.exists(_CONF_FILE): |
| 53 | + _CONFIG = yaml.load(_CONF_FILE) |
| 54 | + if 'server' in _CONFIG: |
| 55 | + _SERVER_CONFIG = _CONFIG['server'] |
| 56 | + if 'address' in _SERVER_CONFIG: |
| 57 | + SERVER_ADDRESS = _SERVER_CONFIG['address'] |
| 58 | + if 'port' in _SERVER_CONFIG: |
| 59 | + SERVER_ADDRESS = _SERVER_CONFIG['port'] |
| 60 | + |
| 61 | + |
42 | 62 | COLOR_STYLES = sorted(list(get_all_styles()))
|
43 | 63 |
|
44 | 64 | MALFORMED_RESPONSE_HTML_PAGE = open(os.path.join(STATIC, 'malformed-response.html')).read()
|
|
0 commit comments