]> git.scottworley.com Git - pinch/commitdiff
Get configuration from config file
authorScott Worley <scottworley@scottworley.com>
Fri, 10 Apr 2020 00:48:02 +0000 (17:48 -0700)
committerScott Worley <scottworley@scottworley.com>
Fri, 10 Apr 2020 00:48:02 +0000 (17:48 -0700)
channels [new file with mode: 0644]
pinch.py

diff --git a/channels b/channels
new file mode 100644 (file)
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
index c77d891eaee06a3db6a0494b2bd84d4c82ad43de..1dbd6679c068ced7cdfdb0162abccd32aa3751ab 100644 (file)
--- a/pinch.py
+++ b/pinch.py
@@ -1,3 +1,4 @@
+import configparser
 import filecmp
 import functools
 import hashlib
 import filecmp
 import functools
 import hashlib
@@ -6,6 +7,7 @@ import os
 import os.path
 import shutil
 import subprocess
 import os.path
 import shutil
 import subprocess
+import sys
 import tempfile
 import types
 import urllib.parse
 import tempfile
 import types
 import urllib.parse
@@ -357,11 +359,11 @@ def check_channel_contents(v: Verification, channel: Channel) -> None:
     v.ok()
 
 
     v.ok()
 
 
-def main() -> None:
+def main(argv: List[str]) -> None:
     v = Verification()
     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)
     fetch(v, channel)
     parse_channel(v, channel)
     fetch_resources(v, channel)
@@ -370,4 +372,4 @@ def main() -> None:
     print(channel)
 
 
     print(channel)
 
 
-main()
+main(sys.argv)