-def read_search_path(conf: configparser.SectionProxy) -> SearchPath:
- mapping: Mapping[str, Type[SearchPath]] = {
- 'alias': AliasSearchPath,
- 'channel': ChannelSearchPath,
- 'git': GitSearchPath,
+K = TypeVar('K')
+V = TypeVar('V')
+
+
+def filter_dict(d: Dict[K, V], fields: Set[K]
+ ) -> Tuple[Dict[K, V], Dict[K, V]]:
+ selected: Dict[K, V] = {}
+ remaining: Dict[K, V] = {}
+ for k, v in d.items():
+ if k in fields:
+ selected[k] = v
+ else:
+ remaining[k] = v
+ return selected, remaining
+
+
+def read_config_section(
+ conf: configparser.SectionProxy) -> Tuple[SearchPath, Optional[Pin]]:
+ mapping: Mapping[str, Tuple[Type[SearchPath], Type[Pin]]] = {
+ 'alias': (AliasSearchPath, AliasPin),
+ 'channel': (ChannelSearchPath, ChannelPin),
+ 'git': (GitSearchPath, GitPin),