Ejemplo n.º 1
0
    def handles(self):
        if self.f.filename and self.f.filename.lower().endswith(self.exts):
            return True

        if self.f.package and self.f.package in make_list(self.package or []):
            return True

        for magic in make_list(self.magic or []):
            if magic in self.f.magic:
                return True
        return False
Ejemplo n.º 2
0
    def handles(self):

        # Temporarily only use the file magic to detect PDF files, as peepdf
        # can fail with invalid/fake PDFs.
        for magic in make_list(self.magic or []):
            if magic in self.f.magic:
                return True
        return False
Ejemplo n.º 3
0
def test_make_list():
    assert make_list(None) == [None]
    assert make_list([]) == []
    assert make_list(()) == []
    assert make_list(1) == [1]
    assert make_list("a") == ["a"]
    assert make_list((1, 2)) == [1, 2]
    assert make_list([3, 4]) == [3, 4]
Ejemplo n.º 4
0
def supported():
    """Returns the supported extensions for this machine. Support for the
    unpacking of numerous file extensions depends on different system packages
    which should be installed on the machine."""
    ret = []
    for plugin in plugins.values():
        if plugin(None).supported():
            for ext in make_list(plugin.exts):
                ret.append(ext)
    return ret