Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
conda install conda-forge::dftbplus
python -m pip install --upgrade pip
pip install .
- name: Lint with Pylint
run: |
pip install '.[lint]'
python -m pylint ThermoScreening
- name: Test with pytest
run: |
pip install '.[test]'
Expand Down
9 changes: 5 additions & 4 deletions ThermoScreening/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@
f"levels are: {logging.getLevelNamesMapping()}"
)

if 'execution_start_time' not in vars(
) and 'execution_start_time' not in globals():
execution_start_time = time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime())
execution_start_time = globals().get(
"execution_start_time",
time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()),
)

logging.setLoggerClass(CustomLogger)
logging.basicConfig(level=os.getenv("THERMOSCREENING_LOGGING_LEVEL", "INFO"))
package_logger = logging.getLogger(__name__)

log_file_env_var = os.getenv("THERMOSCREENING_LOG_FILE")

if log_file_env_var and logging_env_var.lower() != "off":
if log_file_env_var and (logging_env_var or "").lower() != "off":
config.use_log_file = True

if log_file_env_var.lower() != "on" and len(log_file_env_var) > 0:
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ test = [
"coverage",
"pytest-cov"
]
lint = [
"pylint >= 4.0, < 5",
]
docs = [
"sphinx",
]
Expand All @@ -47,3 +50,11 @@ version_file = "ThermoScreening/__version__.py"

[project.scripts]
thermo = "ThermoScreening.cli.thermo:main"

[tool.pylint.main]
fail-under = 7.0
persistent = false
py-version = "3.10"

[tool.pylint.reports]
score = true
21 changes: 21 additions & 0 deletions tests/test_package_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import importlib

import ThermoScreening
import ThermoScreening.config as config


def test_log_file_env_works_without_logging_level(monkeypatch):
monkeypatch.setenv("THERMOSCREENING_LOG_FILE", "on")
monkeypatch.delenv("THERMOSCREENING_LOGGING_LEVEL", raising=False)
monkeypatch.setattr(config, "use_log_file", False)
monkeypatch.setattr(config, "log_file_name", None)

importlib.reload(ThermoScreening)

assert config.use_log_file is True
assert config.log_file_name.startswith("ThermoScreening_")

monkeypatch.delenv("THERMOSCREENING_LOG_FILE", raising=False)
monkeypatch.setattr(config, "use_log_file", False)
monkeypatch.setattr(config, "log_file_name", None)
importlib.reload(ThermoScreening)
Loading