def _get_path_map(self):
res = {}
# if user-specified path_map, it overrides CONFIG
path_map = self.config.get('path_map', [])
#
if not path_map:
return res
if isinstance(path_map, str):
path_map = [path_map]
if isinstance(path_map, Sequence):
for v in path_map:
if ' -> ' not in v:
raise ValueError(f'Path map should be separated as from -> to, {v} specified')
elif v.count(' -> ') > 1:
raise ValueError(f'Path map should be separated as from -> to, {v} specified')
res[v.split(' -> ')[0]] = v.split(' -> ')[1]
elif isinstance(path_map, dict):
for k,v in path_map.items():
res[k] = v
else:
raise ValueError(f'Unacceptable path_mapue for configuration path_map: {path_map}')
return res
评论列表
文章目录