def accessor(self, filename) -> BaseTagReaderWriter: ext = extension_for_file(filename) if ext in self.more_mappings: return self.more_mappings[ext] elif ext in self.BASE_MAP: return self.BASE_MAP[ext] raise UnknownFiletype(ext)
def test_extension_for_file_fallback(tmpdir): path = tmpdir / "testfile.iso" with open(str(path), "wb") as fp: fp.write(os.urandom(1024)) extension_for_file(str(path)) == "iso"
def test_extension_for_file_does_not_exist(): path = Path(__file__).parent / "data" / uuid.uuid4().hex with pytest.raises(FileNotFoundError): extension_for_file(str(path))
def test_extension_for_file(filename, filetype): path = Path(__file__).parent / "data" / filename assert extension_for_file(str(path)) == filetype
def is_supported(self, filename) -> bool: ext = extension_for_file(filename) return ext in self.BASE_MAP or ext in self.more_mappings