File: refill_template_vars.py

package info (click to toggle)
python-eth-utils 5.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,140 kB
  • sloc: python: 5,984; makefile: 238
file content (39 lines) | stat: -rw-r--r-- 895 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3

import os
import sys
from pathlib import Path
import subprocess


def main():
    template_dir = Path(os.path.dirname(sys.argv[0]))
    template_vars_file = template_dir / "template_vars.txt"
    fill_template_vars_script = template_dir / "fill_template_vars.py"

    with open(template_vars_file, "r") as input_file:
        content_lines = input_file.readlines()

    process = subprocess.Popen(
        [sys.executable, str(fill_template_vars_script)],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        text=True,
    )

    for line in content_lines:
        process.stdin.write(line)
        process.stdin.flush()

    stdout, stderr = process.communicate()

    if process.returncode != 0:
        print(f"Error occurred: {stderr}")
        sys.exit(1)

    print(stdout)


if __name__ == "__main__":
    main()