File: update_readme.py

package info (click to toggle)
onnxscript 0.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 12,384 kB
  • sloc: python: 75,957; sh: 41; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 866 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Script to update end-to-end example in README.md."""

updated_readme = []
with open("README.md", encoding="utf-8") as f:
    in_stub = False
    readme = f.readlines()
    for line in readme:
        if not in_stub:
            updated_readme.append(line)
        if line == "```python update-readme\n":
            in_stub = True
            with open(
                "docs/tutorial/examples/hardmax_end_to_end.py", encoding="utf-8"
            ) as example_f:
                example_code = example_f.readlines()[2:]  # Skip the copyright header
                updated_readme += example_code
        if line == "```\n" and in_stub:
            updated_readme.append(line)
            in_stub = False

with open("README.md", "w", encoding="utf-8") as f:
    f.writelines(updated_readme)