def infer_compression(url):
    """
    Given a URL or filename, infer the compression code for tar.
    """
    compression_indicator = url[-2:]
    mapping = dict(gz='z', bz='j', xz='J')
    return mapping.get(compression_indicator, 'z')
