コード例 #1
0
def load_config(config_path: str) -> InfraGraphConfig:
    system_config_path = SYSTEM_CONFIG_ROOT / "config.hocon"
    config = Path(config_path)
    if config.exists():
        logger.info("Using local config")
        config_to_load = config
    elif system_config_path.exists():
        config_to_load = system_config_path
    else:
        logger.error(
            f"No config found to load. Run the `init` command or have a local config '{config_path} available'"
        )
        sys.exit(1)

    hocon_conf = ConfigFactory.parse_file(config_to_load)
    config_dict = json.loads(
        HOCONConverter.to_json(hocon_conf.get("infraGraph")))
    return InfraGraphConfig(**config_dict)
コード例 #2
0
ファイル: test_tool.py プロジェクト: kushwiz/pyhocon
 def test_to_json(self):
     converted = HOCONConverter.to_json(TestHOCONConverter.CONFIG)
     assert [line.strip() for line in TestHOCONConverter.EXPECTED_JSON.split('\n') if line.strip()]\
         == [line.strip() for line in converted.split('\n') if line.strip()]
コード例 #3
0
ファイル: test_tool.py プロジェクト: bkuberek/pyhocon
 def test_to_json(self):
     converted = HOCONConverter.to_json(TestHOCONConverter.CONFIG)
     assert [line.strip() for line in TestHOCONConverter.EXPECTED_JSON.split('\n') if line.strip()]\
         == [line.strip() for line in converted.split('\n') if line.strip()]