Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
py39.py67 linesDownload Raw Back to compat
1import functools2import itertools3import platform4import sys5 6 7def add_ext_suffix_39(vars):8    """9    Ensure vars contains 'EXT_SUFFIX'. pypa/distutils#13010    """11    import _imp12 13    ext_suffix = _imp.extension_suffixes()[0]14    vars.update(15        EXT_SUFFIX=ext_suffix,16        # sysconfig sets SO to match EXT_SUFFIX, so maintain17        # that expectation.18        # https://github.com/python/cpython/blob/785cc6770588de087d09e89a69110af2542be208/Lib/sysconfig.py#L671-L67319        SO=ext_suffix,20    )21 22 23needs_ext_suffix = sys.version_info < (3, 10) and platform.system() == 'Windows'24add_ext_suffix = add_ext_suffix_39 if needs_ext_suffix else lambda vars: None25 26 27# from more_itertools28class UnequalIterablesError(ValueError):29    def __init__(self, details=None):30        msg = 'Iterables have different lengths'31        if details is not None:32            msg += (': index 0 has length {}; index {} has length {}').format(*details)33 34        super().__init__(msg)35 36 37# from more_itertools38def _zip_equal_generator(iterables):39    _marker = object()40    for combo in itertools.zip_longest(*iterables, fillvalue=_marker):41        for val in combo:42            if val is _marker:43                raise UnequalIterablesError()44        yield combo45 46 47# from more_itertools48def _zip_equal(*iterables):49    # Check whether the iterables are all the same size.50    try:51        first_size = len(iterables[0])52        for i, it in enumerate(iterables[1:], 1):53            size = len(it)54            if size != first_size:55                raise UnequalIterablesError(details=(first_size, i, size))56        # All sizes are equal, we can use the built-in zip.57        return zip(*iterables)58    # If any one of the iterables didn't have a length, start reading59    # them until one runs out.60    except TypeError:61        return _zip_equal_generator(iterables)62 63 64zip_strict = (65    _zip_equal if sys.version_info < (3, 10) else functools.partial(zip, strict=True)66)67 
codekingpro/portable-devtools · Team Ai