1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4# Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
5#
6# HDF is dual licensed: you can use it either under the terms of
7# the GPL, or the BSD license, at your option.
8# See the LICENSE file in the root of this repository for complete details.
9import os
10import stat
11from asyncio import subprocess
12
13if __name__ == "__main__":
14    with open(r".\..\hcsVSCode\editor.html", "r", encoding="utf8") as file:
15        ss = file.read()
16    i1 = ss.index("// update js code begin") + len("// update js code begin") + 1
17    i2 = ss.index("// update js code end") - 1
18    with open(r".\dist\main.js", "r", encoding="utf8") as file:
19        destss = file.read()
20    ss = ss[:i1] + destss + ss[i2:]
21    flags = os.O_RDWR | os.O_CREAT
22    modes = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH
23    with os.fdopen(os.open(r".\..\hcsVSCode\editor.html", flags, modes),
24                   "w", encoding="utf-8") as file:
25        file.write(ss)
26    print("replaced")
27