From: Scott Worley Date: Fri, 10 Apr 2020 00:48:02 +0000 (-0700) Subject: Get configuration from config file X-Git-Tag: 1.0~15 X-Git-Url: http://git.scottworley.com/pinch/commitdiff_plain/f15e458d6371d1074d0d91cf7cf9a5312a467b80 Get configuration from config file --- diff --git a/channels b/channels new file mode 100644 index 0000000..d90c172 --- /dev/null +++ b/channels @@ -0,0 +1,4 @@ +[nixos] +url = https://channels.nixos.org/nixos-20.03 +git_repo = https://github.com/NixOS/nixpkgs.git +git_ref = nixos-20.03 diff --git a/pinch.py b/pinch.py index c77d891..1dbd667 100644 --- a/pinch.py +++ b/pinch.py @@ -1,3 +1,4 @@ +import configparser import filecmp import functools import hashlib @@ -6,6 +7,7 @@ import os import os.path import shutil import subprocess +import sys import tempfile import types import urllib.parse @@ -357,11 +359,11 @@ def check_channel_contents(v: Verification, channel: Channel) -> None: v.ok() -def main() -> None: +def main(argv: List[str]) -> None: v = Verification() - channel = Channel(url='https://channels.nixos.org/nixos-20.03', - git_repo='https://github.com/NixOS/nixpkgs.git', - git_ref='nixos-20.03') + config = configparser.ConfigParser() + config.read_file(open(argv[1]), argv[1]) + channel = Channel(**dict(config['nixos'].items())) fetch(v, channel) parse_channel(v, channel) fetch_resources(v, channel) @@ -370,4 +372,4 @@ def main() -> None: print(channel) -main() +main(sys.argv)