comparison data_schema/util.py @ 29:68286d27f27d

FIX: Allow customization of the data stream loader (get_data_stream())
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 08 Jul 2023 16:10:36 +0200
parents 88ee7d1cc0bb
children
comparison
equal deleted inserted replaced
28:db3491e1b590 29:68286d27f27d
80 datapath_sep = '.' 80 datapath_sep = '.'
81 else: 81 else:
82 datapath_sep = '' 82 datapath_sep = ''
83 if packagesubdir: 83 if packagesubdir:
84 psubdir = "." + packagesubdir 84 psubdir = "." + packagesubdir
85 else:
86 psubdir = ""
85 return il_resources.open_binary( 87 return il_resources.open_binary(
86 datapackage + psubdir + datapath_sep 88 datapackage + psubdir + datapath_sep
87 + '.'.join(datapath_dirs), # noqa: E131 89 + '.'.join(datapath_dirs), # noqa: E131
88 datapath_file) 90 datapath_file)
89 else: 91 else:
90 if packagesubdir: 92 if packagesubdir:
91 psubdir = packagesubdir + "/" 93 psubdir = packagesubdir + "/"
94 else:
95 psubdir = ""
92 return pkg_resources.resource_stream( # noqa:E501 # pylint:disable=used-before-assignment 96 return pkg_resources.resource_stream( # noqa:E501 # pylint:disable=used-before-assignment
93 datapackage, psubdir + datapath) 97 datapackage, psubdir + datapath)
94 else: 98 else:
95 raise ValueError( 99 raise ValueError(
96 "URI path for the `data' scheme must not be absolute") 100 "URI path for the `data' scheme must not be absolute")