0

I'm trying to embed 'doit' in my application and so instead of using 'doit' the CLI way, I am looking at the API way.

However, when doing so, I'm unable to figure out how to have 'doit' load the 'pyproject.toml'.

from Globals import *    # part of my application. Has TFW_ROOT.

# from doit.doit_cmd import DoitConfig
from doit.cmd_base import DodoTaskLoader
from doit.doit_cmd import DoitMain  # entry point of doit API

import tomli

# read in the 'doit' config
doit_config = {}

try:
    with open(TFW_ROOT + '/pyproject.toml', "rb") as fd:
        doit_config = tomli.load(fd)
except tomli.TOMLDecodeError:
    print("'doit' configuration has invalid data. Check {TFW_ROOT}/pyproject.toml")

# TODO:
# instantiate doit classes and customise properties like BIN_NAME

# doitconfig = DoitConfig()

task_loader = DodoTaskLoader()
task_loader.load_doit_config()  # I thought this'd be the place, but No.

doit_main = DoitMain(task_loader)
doit_main.BIN_NAME = 'myFoo'

Later if I say e.g. doit_main.run('list'), doit looks for a dodofile.py, instead of the filename as configured in the pyproject.toml. Obviously it is not reading it. I tried to read in the toml myself, but could not find a class that I should be initialising with it.

I looked thru the source code, but could not figure out how pyproject.toml is loaded by doit.

Any ideas?

yogmk
  • 161
  • 10

0 Answers0