]> git.scottworley.com Git - pinch/blobdiff - pinch.py
Require type to be specified in config
[pinch] / pinch.py
index f5fbb481bea3cb0df30bf45f12c40d58dda55f83..ea380a3a332137e2b70fbcb507603c800687ebdb 100644 (file)
--- 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: