Example #1
0
def load_dotenv(create=True):
    """ """
    auto_discover = find_dotenv()
    provided_env_file = os.environ.get("HYPERFHIR_CONFIGURATION_FILE", "")
    if provided_env_file == "" and auto_discover == "":
        env_file = os.path.join(os.getcwd(), ".env")
    elif provided_env_file:
        env_file = provided_env_file
    else:
        env_file = auto_discover

    env_file = pathlib.Path(env_file)
    if not env_file.exists() and create:
        env_file.touch()
    elif not env_file.exists():
        raise LookupError(f"{env_file} doesn't found.")
    if not env_file.is_file():
        raise ValueError(f"{env_file} is not file.")
    override = auto_discover != "" and provided_env_file != ""
    _load_dotenv(dotenv_path=env_file, override=override)
Example #2
0
import os
from pathlib import Path
from dotenv import load_dotenv as _load_dotenv

APP_FOLDER = 'radiopi'
CONFIG_PATH = os.path.join(Path.home(), '.config', APP_FOLDER)
MY_STATIONS = os.path.join(CONFIG_PATH, 'stations.yml')

_load_dotenv(os.path.join(os.path.dirname(__file__), '..', '.env'))
_load_dotenv(os.path.join(CONFIG_PATH, '.env'))

# create config folder
Path(CONFIG_PATH).mkdir(parents=True, exist_ok=True)
Example #3
0
import sys as _sys
import os as _os
from dotenv import load_dotenv as _load_dotenv

_load_dotenv()

MATRIX_URL = _os.getenv('MATRIX_URL', 'https://matrix.org')
MATRIX_USER_ACCESS_TOKEN = _os.getenv('MATRIX_USER_ACCESS_TOKEN', '')
FLASK_HOST = _os.getenv('FLASK_HOST', '0.0.0.0')
FLASK_PORT = _os.getenv('FLASK_PORT', 3000)

if not MATRIX_USER_ACCESS_TOKEN:
    print('Please define an env variable for MATRIX_USER_ACCESS_TOKEN')
Example #4
0
def load_dotenv():  # pragma: no cover
    '''Loads environment from a .env file'''
    if path.exists(DOTENV_PATH):
        LOGGER.info('Loading environment from .env file')
        _load_dotenv(DOTENV_PATH)
Example #5
0
import os as _os
from pathlib import Path as _Path

from dotenv import load_dotenv as _load_dotenv

env_path = _Path('.') / '.env'
_load_dotenv(dotenv_path=env_path)


def GET_PATH():
    """Retrieves the current directory"""
    return _os.path.dirname(_os.path.abspath(__file__))


def _split_string(input_to_split: str, delimiter: str = ','):
    """Split a given input string by given delimiter

    Arguments:
        input_to_split {str} -- String to split

    Keyword Arguments:
        delimiter {str} -- Delimiter to use (default: {','})

    Returns:
        {list} -- List of splitted strings
    """
    splitted_string = input_to_split.lower().replace(' ', '').split(delimiter)
    return splitted_string


FLASK_APP_NAME = _os.getenv("FLASK_APP_NAME")