Exemplo n.º 1
0
Arquivo: rgio.py Projeto: mxjeff/rgain
 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)
Exemplo n.º 2
0
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"
Exemplo n.º 3
0
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))
Exemplo n.º 4
0
def test_extension_for_file(filename, filetype):
    path = Path(__file__).parent / "data" / filename
    assert extension_for_file(str(path)) == filetype
Exemplo n.º 5
0
Arquivo: rgio.py Projeto: mxjeff/rgain
 def is_supported(self, filename) -> bool:
     ext = extension_for_file(filename)
     return ext in self.BASE_MAP or ext in self.more_mappings