From b6feacaa7909731e05522eb193cced4e93e016b2 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 10 Jul 2024 20:30:41 -0600 Subject: [PATCH] Get environments from tox.ini --- .github/workflows/try_parser.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/try_parser.py b/.github/workflows/try_parser.py index 9f528d5070..61fba9a2cd 100644 --- a/.github/workflows/try_parser.py +++ b/.github/workflows/try_parser.py @@ -1,18 +1,26 @@ from tox.config.source.ini import IniSource from tox.config.types import EnvList from pathlib import Path -from ipdb import set_trace from tox.config.cli.parse import get_options from tox.session.state import State +from tox.config.sets import CoreConfigSet +from tox.config.source.tox_ini import ToxIni +from collections import defaultdict +from json import dumps + +tox_ini_path = Path( + "/home/tigre/github/ocelotl/opentelemetry-python-contrib/tox.ini" +) ini_source = IniSource( Path("/home/tigre/github/ocelotl/opentelemetry-python-contrib/tox.ini") ) +tox_ini = ToxIni(tox_ini_path) + state = State(get_options(), []) conf = state.conf -set_trace() tox_section = [section for section in ini_source.sections()][0] @@ -23,4 +31,12 @@ raw = tox_section_loader.load_raw("envlist", conf, None) -set_trace() +core_config_set = CoreConfigSet(conf, tox_section, tox_ini_path.parent, tox_ini_path) + +loaders = tox_ini.get_loaders(tox_section, base=[], override_map=defaultdict(list, {}), conf=core_config_set) + +core_config_set.loaders.extend(loaders) + +result = core_config_set.load("env_list") + +print(dumps(result.envs, indent=4))