def read_toml(content): check_section_header(content) for k, v in toml.loads(content, collections.OrderedDict).items(): if len(v.values()) and isinstance(list(v.values())[0], dict): raise RuntimeError('malformed section header -- forgot quotes?', k) pname, version = split_name(k) yield WhitelistRule(pname=pname, version=version, **v)
def test_split_name(): assert split_name('network-2.6.3.2-r1.cabal') == ( 'network', '2.6.3.2-r1.cabal') assert split_name('python2.7-pytest-runner-2.6.2.drv') == ( 'python2.7-pytest-runner', '2.6.2') assert split_name('hook.drv') == ('hook', None)