-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.py
38 lines (30 loc) · 979 Bytes
/
update.py
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
import re
import subprocess
from pathlib import Path
import jinja2
def main():
env = jinja2.Environment(
loader=jinja2.loaders.FileSystemLoader(Path(__file__).parent)
)
template = env.get_template("Formula/snowflake-cli.tmpl.rb")
packages = subprocess.check_output(["poet", "snowflake-cli"], encoding="utf-8")
sf_pattern = (
r"\s+resource \"snowflake-cli\" do\s+url \"(.+)\"\s+sha256 \"(\w+)\"\s+end\n"
)
match = re.findall(sf_pattern, packages)
if not match:
raise ValueError("snowflake dependency not present in deps")
sf_url, sf_sha = match[0]
version = subprocess.check_output(["snow", "--version"], encoding="utf-8").split()[
-1
]
with open("Formula/snowflake-cli.rb", "w+") as fh:
fh.write(
template.render(
sf_url=sf_url,
sf_sha=sf_sha,
version=version,
)
)
if __name__ == "__main__":
main()