diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-08-09 01:08:47 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-08-09 01:08:47 +0530 |
commit | 115add43876964956917bf596c1d0b148c5b3c26 (patch) | |
tree | 3274c61d8d9440b414394c34b1ac76a8cb300116 /devscripts/update-formulae.py | |
parent | c4b6c5c7c9eb0aa448d03c1540580cdd92737aa8 (diff) | |
download | hypervideo-pre-115add43876964956917bf596c1d0b148c5b3c26.tar.lz hypervideo-pre-115add43876964956917bf596c1d0b148c5b3c26.tar.xz hypervideo-pre-115add43876964956917bf596c1d0b148c5b3c26.zip |
[devscripts] Create `utils` and refactor
Diffstat (limited to 'devscripts/update-formulae.py')
-rw-r--r-- | devscripts/update-formulae.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/devscripts/update-formulae.py b/devscripts/update-formulae.py index 96b56b932..e79297f53 100644 --- a/devscripts/update-formulae.py +++ b/devscripts/update-formulae.py @@ -1,5 +1,10 @@ #!/usr/bin/env python3 +""" +Usage: python3 ./devscripts/update-formulae.py <path-to-formulae-rb> <version> +version can be either 0-aligned (yt-dlp version) or normalized (PyPi version) +""" + # Allow direct execution import os import sys @@ -11,8 +16,7 @@ import json import re import urllib.request -# usage: python3 ./devscripts/update-formulae.py <path-to-formulae-rb> <version> -# version can be either 0-aligned (yt-dlp version) or normalized (PyPl version) +from devscripts.utils import read_file, write_file filename, version = sys.argv[1:] @@ -27,11 +31,9 @@ tarball_file = next(x for x in pypi_release['urls'] if x['filename'].endswith('. sha256sum = tarball_file['digests']['sha256'] url = tarball_file['url'] -with open(filename) as r: - formulae_text = r.read() +formulae_text = read_file(filename) formulae_text = re.sub(r'sha256 "[0-9a-f]*?"', 'sha256 "%s"' % sha256sum, formulae_text, count=1) formulae_text = re.sub(r'url "[^"]*?"', 'url "%s"' % url, formulae_text, count=1) -with open(filename, 'w') as w: - w.write(formulae_text) +write_file(filename, formulae_text) |