Exemplo n.º 1
0
    def test_partial(self):

        def test_func(a, b):
            pass

        wrapped = partial(test_func, a=2)
        assert wrapped.__name__ == 'test_func'
Exemplo n.º 2
0
def get_extractor(location, kinds=all_kinds):
    """
    Return an extraction callable that can extract the file at location or
    an None if no extract function is found.
    """
    assert location
    location = os.path.abspath(os.path.expanduser(location))
    extractors = get_extractors(location, kinds)
    if not extractors:
        return None

    if len(extractors) == 2:
        extractor1, extractor2 = extractors
        nested_extractor = functional.partial(extract_twice,
                                             extractor1=extractor1,
                                             extractor2=extractor2)
        return nested_extractor
    elif len(extractors) == 1:
        return extractors[0]
    else:
        return None
Exemplo n.º 3
0
    return warnings

# High level aliases to lower level extraction functions
########################################################


extract_tar = libarchive2.extract
extract_patch = patch.extract

extract_deb = libarchive2.extract
extract_ar = libarchive2.extract
extract_msi = sevenzip.extract
extract_cpio = libarchive2.extract

# sevenzip should be best at extracting 7zip but most often libarchive is better first
extract_7z = functional.partial(extract_with_fallback, extractor1=libarchive2.extract, extractor2=sevenzip.extract)

# libarchive is best for the run of the mill zips, but sevenzip sometimes is better
extract_zip = functional.partial(extract_with_fallback, extractor1=libarchive2.extract, extractor2=sevenzip.extract)

extract_springboot = functional.partial(try_to_extract, extractor=extract_zip)

extract_iso = sevenzip.extract
extract_rar = libarchive2.extract
extract_rpm = sevenzip.extract
extract_xz = sevenzip.extract
extract_lzma = sevenzip.extract
extract_squashfs = sevenzip.extract
extract_cab = sevenzip.extract
extract_nsis = sevenzip.extract
extract_ishield = sevenzip.extract