From: Scott Worley Date: Mon, 15 Jun 2020 18:38:12 +0000 (-0700) Subject: Require type to be specified in config X-Git-Tag: 2.0.0~19 X-Git-Url: http://git.scottworley.com/pinch/commitdiff_plain/7f4c3ace15d9dc80a366743e5f7a38ec7b2af201?ds=sidebyside Require type to be specified in config --- diff --git a/channels b/channels index dc1f754..a4b984d 100644 --- a/channels +++ b/channels @@ -1,9 +1,11 @@ [nixos] +type = channel channel_url = https://channels.nixos.org/nixos-20.03 git_repo = https://github.com/NixOS/nixpkgs.git git_ref = nixos-20.03 [nixos-hardware] +type = git git_repo = https://github.com/NixOS/nixos-hardware.git git_ref = master diff --git a/default.nix b/default.nix index c2c751c..3209685 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, }: buildPythonPackage rec { pname = "pinch"; - version = "1.5.1"; + version = "2.0.0-pre"; src = lib.cleanSource ./.; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; doCheck = true; diff --git a/pinch.py b/pinch.py index f5fbb48..ea380a3 100644 --- a/pinch.py +++ b/pinch.py @@ -22,9 +22,11 @@ from typing import ( Dict, Iterable, List, + Mapping, NamedTuple, NewType, Tuple, + Type, Union, ) @@ -585,11 +587,12 @@ def git_revision_name(v: Verification, channel: TarrableSearchPath) -> str: def read_search_path(conf: configparser.SectionProxy) -> SearchPath: - if 'alias_of' in conf: - return AliasSearchPath(**dict(conf.items())) - if 'channel_url' in conf: - return ChannelSearchPath(**dict(conf.items())) - return GitSearchPath(**dict(conf.items())) + mapping: Mapping[str, Type[SearchPath]] = { + 'alias': AliasSearchPath, + 'channel': ChannelSearchPath, + 'git': GitSearchPath, + } + return mapping[conf['type']](**dict(conf.items())) def read_config(filename: str) -> configparser.ConfigParser: diff --git a/setup.py b/setup.py index b7d3a26..e5d1ebe 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name="pinch", - version="1.5.1", + version="2.0.0-pre", py_modules=['pinch'], entry_points={"console_scripts": ["pinch = pinch:main"]}, ) diff --git a/tests/alias.sh b/tests/alias.sh index 928ceab..dce5747 100755 --- a/tests/alias.sh +++ b/tests/alias.sh @@ -6,6 +6,7 @@ foo_setup cat >> "$conf" < "$conf" < "$conf2" <> "$conf" <