Oct-29-2020, 11:31 PM
i would like a library function that can read the first 4096 bytes of a named file (no more than that, less if it can) and detect if it is a compressed file or not and return an indicator of which type of compression or not..
0 for not compressed
1 ... for compressed
or names may be given as strings. i do not want to have to call some program since i would like for this to be portable. it should support gzip, bzip2, lzma, pkzip, and xz. and anything else Python can support. an alternative is one that can determine this from a bytes string of the starting contents of the file (the caller reads in some of the file).
0 for not compressed
1 ... for compressed
or names may be given as strings. i do not want to have to call some program since i would like for this to be portable. it should support gzip, bzip2, lzma, pkzip, and xz. and anything else Python can support. an alternative is one that can determine this from a bytes string of the starting contents of the file (the caller reads in some of the file).