CLN: consolidate compression inference as much as possible
we have 3 copies of the compression inference routines in `parser.py, parser.py, and io/common.py`. See how much we can reduce this (_some_ is necessary as sometimes we need to actually return a file handle or need to read in and re-wrap).

xref #12175 
