def test_multiple(self): names = OrderedDict() names['audio-volume-muted.*'] = 2 names['battery-caution-charging.*'] = 1 dfiles = utils.scan_files(DATA_DIR, *names) for name, length in names.items(): assert len(dfiles[name]) == length
def test_only_svg(self): name = 'audio-volume-muted.svg' dfiles = utils.scan_files(DATA_DIR, name) result = dfiles[name] assert len(result) == 1 svg = os.path.join(DATA_DIR, 'svg', 'audio-volume-muted.svg') assert svg in result
def test_audio_volume_muted(self): name = 'audio-volume-muted.*' dfiles = utils.scan_files(DATA_DIR, name) result = dfiles[name] assert len(result) == 2 png = os.path.join(DATA_DIR, 'png', 'audio-volume-muted.png') assert png in result svg = os.path.join(DATA_DIR, 'svg', 'audio-volume-muted.svg') assert svg in result
def test_audio_volume_muted(self): name = "audio-volume-muted.*" dfiles = utils.scan_files(DATA_DIR, name) result = dfiles[name] assert len(result) == 2 png = os.path.join(DATA_DIR, "png", "audio-volume-muted.png") assert png in result svg = os.path.join(DATA_DIR, "svg", "audio-volume-muted.svg") assert svg in result
def __call__(self, *names): d = {} seen = set() set_names = set() for n in names: root, ext = os.path.splitext(n) if ext: set_names.add(n) else: set_names.add(n + ".*") for directory in self.directories: d_matches = scan_files(directory, *(set_names - seen)) for name, paths in d_matches.items(): if paths: d[name if name in names else name[:-2]] = Img.from_path( paths[0]) seen.add(name) if seen != set_names: msg = "Wasn't able to find images corresponding to the names: {}" raise LoadingError(msg.format(set_names - seen)) return d