Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix docs config
Browse files Browse the repository at this point in the history
  • Loading branch information
blankdots committed Nov 22, 2018
1 parent 4a75fb4 commit b2cf830
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
32 changes: 31 additions & 1 deletion beacon_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,37 @@
import os
import datetime

from .conf.config import parse_configuration_file
from configparser import ConfigParser
from collections import namedtuple


def parse_configuration_file(path):
"""Parse configuration file."""
config = ConfigParser()
config.read(path)
config_vars = {
'title': config.get('beacon_general_info', 'title'),
'version': config.get('beacon_general_info', 'version'),
'author': config.get('beacon_general_info', 'author'),
'license': config.get('beacon_general_info', 'license'),
'copyright': config.get('beacon_general_info', 'copyright'),
'apiVersion': config.get('beacon_api_info', 'apiVersion'),
'beaconId': config.get('beacon_api_info', 'beaconId'),
'description': config.get('beacon_api_info', 'description'),
'url': config.get('beacon_api_info', 'url'),
'alturl': config.get('beacon_api_info', 'alturl'),
'createtime': config.get('beacon_api_info', 'createtime'),
'org_id': config.get('organisation_info', 'org_id'),
'org_name': config.get('organisation_info', 'org_name'),
'org_description': config.get('organisation_info', 'org_description'),
'org_address': config.get('organisation_info', 'org_address'),
'org_welcomeUrl': config.get('organisation_info', 'org_welcomeUrl'),
'org_contactUrl': config.get('organisation_info', 'org_contactUrl'),
'org_logoUrl': config.get('organisation_info', 'org_logoUrl'),
'org_info': config.get('organisation_info', 'org_info'),
}
return namedtuple("Config", config_vars.keys())(*config_vars.values())


CONFIG = parse_configuration_file(os.environ.get('CONFIG_FILE', './beacon_api/conf/config.ini'))

Expand Down
32 changes: 0 additions & 32 deletions beacon_api/conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,9 @@
"""

import os

from configparser import ConfigParser
from collections import namedtuple

import asyncpg


def parse_configuration_file(path):
"""Parse configuration file."""
config = ConfigParser()
config.read(path)
config_vars = {
'title': config.get('beacon_general_info', 'title'),
'version': config.get('beacon_general_info', 'version'),
'author': config.get('beacon_general_info', 'author'),
'license': config.get('beacon_general_info', 'license'),
'copyright': config.get('beacon_general_info', 'copyright'),
'apiVersion': config.get('beacon_api_info', 'apiVersion'),
'beaconId': config.get('beacon_api_info', 'beaconId'),
'description': config.get('beacon_api_info', 'description'),
'url': config.get('beacon_api_info', 'url'),
'alturl': config.get('beacon_api_info', 'alturl'),
'createtime': config.get('beacon_api_info', 'createtime'),
'org_id': config.get('organisation_info', 'org_id'),
'org_name': config.get('organisation_info', 'org_name'),
'org_description': config.get('organisation_info', 'org_description'),
'org_address': config.get('organisation_info', 'org_address'),
'org_welcomeUrl': config.get('organisation_info', 'org_welcomeUrl'),
'org_contactUrl': config.get('organisation_info', 'org_contactUrl'),
'org_logoUrl': config.get('organisation_info', 'org_logoUrl'),
'org_info': config.get('organisation_info', 'org_info'),
}
return namedtuple("Config", config_vars.keys())(*config_vars.values())


URL = os.environ.get('DATABASE_URL', 'postgresql://localhost:5432').split('/')[2]
POSTGRES = {
'user': os.environ.get('DATABASE_USER', 'beacon'),
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def __getattr__(cls, name):

# List modules need to be mocked
MOCK_MODULES = ['aiohttp', 'asyncpg', 'cyvcf2', 'cryptography.hazmat', 'cryptography.hazmat.primitives', 'cryptography.hazmat.backends',
'Cython', 'numpy', 'jwt', 'cryptography.hazmat.primitives.asymmetric', 'cryptography.hazmat.primitives.asymmetric.rsa']
'Cython', 'numpy', 'jwt', 'cryptography.hazmat.primitives.asymmetric', 'cryptography.hazmat.primitives.asymmetric.rsa',
'configparser', 'collections']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

# If your documentation needs a minimal Sphinx version, state it here.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
long_description="",
packages=['beacon_api', 'beacon_api/utils', 'beacon_api/conf', 'beacon_api/schemas', 'beacon_api/api'],
# If any package contains *.json, include them:
package_data={'': ['*.json']},
package_data={'': ['*.json', '*.ini']},
entry_points={
'console_scripts': [
'beacon=beacon_api.app:main',
Expand Down

0 comments on commit b2cf830

Please sign in to comment.