Skip to content

main.py

Main function, used as an entry point for pip.

Source code in src/smiffer/__init__.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
def main():
    """Main function, used as an entry point for `pip`."""
    # Starting the timer to compute execution time.
    start_time: float = time()

    # Saving the starting launching time.
    begin_date: str = datetime.now().strftime("%d/%m/%Y - %H:%M:%S")

    # Saving the starting launching time.
    date: str = datetime.now().strftime("%Y_%m_%d_%H-%M-%S")

    argument = parse_argument(__version__)

    # YAML parsing.
    yaml = parse_yaml(argument.parameter, argument.verbose)
    yaml.clean()

    if argument.verbose:
        print(yaml)

    # Metadata linked to the arguments.
    argument_data: dict = {
        "input_file": argument.input,
        "output_directory": argument.output,
        "apbs_file": argument.apbs,
        "parameter_file": argument.parameter,
    }

    # Metadata linked to script time execution.
    timing_data: dict = {
        "script_version": __version__,
        "launch_time": begin_date,
        "end_time": datetime.now().strftime("%d/%m/%Y - %H:%M:%S"),
        "execution_time": f"{time() - start_time} seconds",
    }

    grid(yaml=yaml, argument=argument, date=date)

    # JSON writing.
    json: WriteJson = WriteJson(
        yaml_parser=yaml, argument=argument_data, timing=timing_data
    )

    if argument.verbose:
        print(json)

    json.write(path=argument.output, verbose=argument.verbose, date=date)