Skip to content

Commit

Permalink
Switch to conf path from conf environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannik Hoffjann committed Jul 5, 2019
1 parent 792e892 commit 1f9a450
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PYTHONPATH=.
ESQUE_ENV=dev
ESQUE_CONF_PATH=esque.cfg
11 changes: 4 additions & 7 deletions esque/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import configparser
import random
import string
from distutils.sysconfig import get_python_lib
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple

import click

from esque.environment import ESQUE_ENV
from esque.environment import ESQUE_CONF_PATH
from esque.errors import ConfigNotExistsException, ContextNotDefinedException

RANDOM = "".join(random.choices(string.ascii_lowercase, k=8))
Expand All @@ -19,19 +18,17 @@


def config_dir() -> Path:
if ESQUE_ENV == "dev":
return Path(__file__).parent.parent
return Path(click.get_app_dir("esque", force_posix=True))


def config_path() -> Path:
if ESQUE_CONF_PATH:
return Path(ESQUE_CONF_PATH)
return config_dir() / "esque.cfg"


def sample_config_path() -> Path:
if ESQUE_ENV == "dev":
return Path(__file__).parent / "config" / "sample_config.cfg"
return Path(get_python_lib()) / "esque" / "config" / "sample_config.cfg"
return Path(__file__).parent / "config" / "sample_config.cfg"


class Config:
Expand Down
2 changes: 1 addition & 1 deletion esque/environment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import os

ESQUE_ENV = os.environ.get("ESQUE_ENV")
ESQUE_CONF_PATH = os.environ.get("ESQUE_CONF_PATH")

0 comments on commit 1f9a450

Please sign in to comment.