forked from snowflakedb/homebrew-snowflake-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.py
More file actions
33 lines (24 loc) · 862 Bytes
/
update.py
File metadata and controls
33 lines (24 loc) · 862 Bytes
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
import re
import subprocess
from pathlib import Path
from textwrap import indent
import jinja2
def main():
env = jinja2.Environment(
loader=jinja2.loaders.FileSystemLoader(Path(__file__).parent)
)
template = env.get_template("Formula/snowcli.tmpl.rb")
packages = subprocess.check_output(["poet", "snowflake-cli-labs"], encoding="utf-8")
sf_pattern = r'\s+resource \"snowflake-cli-labs\" 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]
with open("Formula/snowcli.rb", "w+") as fh:
fh.write(template.render(
sf_url=sf_url,
sf_sha=sf_sha,
packages=indent(packages, " ")
))
if __name__ == '__main__':
main()