"megatron/legacy/model/module.py" did not exist on "73af1290390a33c22ab1a78de7b0cb05b555aa47"
regex-to-grammar.py 431 Bytes
Newer Older
mashun1's avatar
v1  
mashun1 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import json, subprocess, sys, os

assert len(sys.argv) >= 2
[_, pattern, *rest] = sys.argv

print(subprocess.check_output(
    [
        "python",
        os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        "json_schema_to_grammar.py"),
        *rest,
        "-",
        "--raw-pattern",
    ],
    text=True,
    input=json.dumps({
        "type": "string",
        "pattern": pattern,
    }, indent=2)))