From f15e458d6371d1074d0d91cf7cf9a5312a467b80 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 9 Apr 2020 17:48:02 -0700 Subject: [PATCH] Get configuration from config file --- channels | 4 ++++ pinch.py | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 channels 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) -- 2.44.1