Coverage for sparkle/configurator/configurator_cli.py: 0%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-05 14:48 +0000

1#!/usr/bin/env python3 

2"""Configurator CLI wrapper class to standardise I/O of Configurators.""" 

3 

4import sys 

5import subprocess 

6from pathlib import Path 

7import implementations 

8 

9if __name__ == "__main__": 

10 args = sys.argv 

11 configurator_name = args[1] 

12 output_source = Path(args[2]) 

13 output_target = Path(args[3]) 

14 configurator_call = args[4:] 

15 # 1. Resolve for which Configurator we are standardising 

16 configurator = implementations.resolve_configurator(configurator_name) 

17 # 2. Execute the call, output is automatically piped to the caller's set output 

18 subprocess.run(configurator_call) 

19 # 3. Standardise the output for Sparkle 

20 # 3a. Make sure the output file exists 

21 output_target.open("a").close() 

22 # 3b. Have the configurator implementation organise the output 

23 configurator.organise_output(output_source=output_source, 

24 output_target=output_target) 

25 print(f"Organising done! See {output_target}")