File size: 589 Bytes
105b369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from pathlib import Path
from typing import Optional, Dict

from phi.utils.log import logger


def read_pyproject_phidata(pyproject_file: Path) -> Optional[Dict]:
    logger.debug(f"Reading {pyproject_file}")
    try:
        import tomli

        pyproject_dict = tomli.loads(pyproject_file.read_text())
        phidata_conf = pyproject_dict.get("tool", {}).get("phidata", None)
        if phidata_conf is not None and isinstance(phidata_conf, dict):
            return phidata_conf
    except Exception as e:
        logger.error(f"Could not read {pyproject_file}: {e}")
    return None