def read_chunk(self, chunksize):
        chunksize = int(round(chunksize))
        s = self.proc.stdout.read(self.nchannels * chunksize * self.nbytes)
        data_type = {1: "int8", 2: "int16", 4: "int32"}[self.nbytes]
        if hasattr(np, "frombuffer"):
            result = np.frombuffer(s, dtype=data_type)
        else:
            result = np.fromstring(s, dtype=data_type)
        result = (1.0 * result / 2 ** (8 * self.nbytes - 1)).reshape(
            (int(len(result) / self.nchannels), self.nchannels)
        )
        pad = np.zeros((chunksize - len(result), self.nchannels), dtype=result.dtype)
        result = np.concatenate([result, pad])
        self.pos = self.pos + chunksize
        return result
read_chunk(self=<moviepy.audio.io.readers.FFMPEG_AudioReader object at 0x7f8c0a2042e0>, chunksize=200000, self.bitrate=127, self.buffer=None, self.buffer_startframe=1, self.buffersize=200000, self.codec='pcm_s16le', self.duration=9.64, self.filename='media/chaplin.mp4', self.format='s16le', self.fps=44100, self.infos={'video_found': True, 'audio_found': True, 'metadata': {'major_brand': 'isom', 'minor_version': '512', 'compatible_brands': 'isomiso2avc1mp41', 'encoder': 'Lavf57.25.100'}, 'inputs': [{'streams': [{'input_number': 0, 'stream_number': 0, 'stream_type': 'video', 'language': None, 'default': True, 'size': [640, 360], 'bitrate': 495, 'fps': 25.0, 'metadata': {'handler_name': 'VideoHandler'}}, {'input_number': 0, 'stream_number': 1, 'stream_type': 'audio', 'language': None, 'default': True, 'fps': 44100, 'bitrate': 127, 'metadata': {'handler_name': 'SoundHandler'}}], 'input_number': 0}], 'duration': 9.64, 'bitrate': 631, 'start': 0.0, 'default_video_input_number': 0, 'default_video_stream_number': 0, 'video_size': [640, 360], 'video_bitrate': 495, 'video_fps': 25.0, 'default_audio_input_number': 0, 'default_audio_stream_number': 1, 'audio_fps': 44100, 'audio_bitrate': 127, 'video_n_frames': 241, 'video_duration': 9.64}, self.n_frames=425124, self.nbytes=2, self.nchannels=2, self.pos=0, self.proc=<Popen: returncode: None args: ['/local/rcs/XXX/miniforge3/envs/Zulko+mov...>)


result = np.frombuffer(s, dtype=data_type)

<moviepy.audio.io.readers.FFMPEG_AudioReader object at 0x7f8c0a2042e0>

{'video_found': True, 'audio_found': True, 'metadata': {'major_brand': 'isom', 'minor_version': '512', 'compatible_brands': 'isomiso2avc1mp41', 'encoder': 'Lavf57.25.100'}, 'inputs': [{'streams': [{'input_number': 0, 'stream_number': 0, 'stream_type': 'video', 'language': None, 'default': True, 'size': [640, 360], 'bitrate': 495, 'fps': 25.0, 'metadata': {'handler_name': 'VideoHandler'}}, {'input_number': 0, 'stream_number': 1, 'stream_type': 'audio', 'language': None, 'default': True, 'fps': 44100, 'bitrate': 127, 'metadata': {'handler_name': 'SoundHandler'}}], 'input_number': 0}], 'duration': 9.64, 'bitrate': 631, 'start': 0.0, 'default_video_input_number': 0, 'default_video_stream_number': 0, 'video_size': [640, 360], 'video_bitrate': 495, 'video_fps': 25.0, 'default_audio_input_number': 0, 'default_audio_stream_number': 1, 'audio_fps': 44100, 'audio_bitrate': 127, 'video_n_frames': 241, 'video_duration': 9.64}

<Popen: returncode: None args: ['/local/rcs/XXX/miniforge3/envs/Zulko+mov...>


result = (1.0 * result / 2 ** (8 * self.nbytes - 1)).reshape(


def max_volume(self, stereo=False, chunksize=50000, logger=None):
        stereo = stereo and self.nchannels > 1
        maxi = np.zeros(self.nchannels)
        for chunk in self.iter_chunks(chunksize=chunksize, logger=logger):
            maxi = np.maximum(maxi, abs(chunk).max(axis=0))
        return maxi if stereo else maxi[0]
max_volume(self=<moviepy.audio.AudioClip.AudioClip object at 0x7f8c0a8d9880>, stereo=False, chunksize=50000, logger=None, self.duration=1, self.end=1, self.fps=44100, self.make_frame=<function get_mono_wave.<locals>.make_mono_frame at 0x7f8c0a9c6310>, self.memoize=False, self.memoized_frame=None, self.memoized_t=None, self.nchannels=1, self.start=0)


def test_clip_with_end(duration, start, end, expected_start, expected_duration):
    clip = ColorClip(color=(255, 0, 0), size=(2, 2), duration=duration).with_fps(1)
    if start is not None:
        clip = clip.with_start(start)
    else:
        clip.start = None
    clip = clip.with_end(end)
    assert clip.start == expected_start
    assert clip.duration == expected_duration
test_clip_with_end(duration=3, start=1, end=2, expected_start=1, expected_duration=1)

{start=0, end=3, duration=3, memoize=False, memoized_t=None, memoized_frame=None, mask=None, audio=None, relative_pos=False, layer=0, is_mask=False, has_constant_size=True, size=(2, 2), img=array([[[255,   0,   0],        [255,   0,   0]],       [[255,   0,   0],        [255,   0,   0]]]), fps=1}

{start=1, end=4, duration=3, memoize=False, memoized_t=None, memoized_frame=None, mask=None, audio=None, relative_pos=False, layer=0, is_mask=False, has_constant_size=True, size=(2, 2), img=array([[[255,   0,   0],        [255,   0,   0]],       [[255,   0,   0],        [255,   0,   0]]]), fps=1}

{start=1, end=2, duration=1, memoize=False, memoized_t=None, memoized_frame=None, mask=None, audio=None, relative_pos=False, layer=0, is_mask=False, has_constant_size=True, size=(2, 2), img=array([[[255,   0,   0],        [255,   0,   0]],       [[255,   0,   0],        [255,   0,   0]]]), fps=1}


{start=1, end=4, duration=3, memoize=False, memoized_t=None, memoized_frame=None, mask=None, audio=None, relative_pos=False, layer=0, is_mask=False, has_constant_size=True, size=(2, 2), img=array([[[255,   0,   0],        [255,   0,   0]],       [[255,   0,   0],        [255,   0,   0]]]), fps=1}


{start=1, end=2, duration=1, memoize=False, memoized_t=None, memoized_frame=None, mask=None, audio=None, relative_pos=False, layer=0, is_mask=False, has_constant_size=True, size=(2, 2), img=array([[[255,   0,   0],        [255,   0,   0]],       [[255,   0,   0],        [255,   0,   0]]]), fps=1}


def test_clip_copy(copy_func):
    clip = Clip()
    other_clip = Clip()
    for attr in clip.__dict__:
        setattr(clip, attr, "foo")
    copied_clip = copy_func(clip)
    for attr in copied_clip.__dict__:
        assert getattr(copied_clip, attr) == getattr(clip, attr)
        assert getattr(copied_clip, attr) != getattr(other_clip, attr)
test_clip_copy(copy_func=<function <lambda> at 0x7f8c0a895700>)

{start=0, end=None, duration=None, memoize=False, memoized_t=None, memoized_frame=None}

{start='foo', end=None, duration=None, memoize=False, memoized_t=None, memoized_frame=None}

{start='foo', end='foo', duration=None, memoize=False, memoized_t=None, memoized_frame=None}

{start='foo', end='foo', duration='foo', memoize=False, memoized_t=None, memoized_frame=None}

{start='foo', end='foo', duration='foo', memoize='foo', memoized_t=None, memoized_frame=None}

{start='foo', end='foo', duration='foo', memoize='foo', memoized_t='foo', memoized_frame=None}

{start='foo', end='foo', duration='foo', memoize='foo', memoized_t='foo', memoized_frame='foo'}


def subprocess_call(cmd, logger="bar"):
    logger = proglog.default_bar_logger(logger)
    logger(message="MoviePy - Running:\n>>> " + " ".join(cmd))
    popen_params = cross_platform_popen_params(
        {"stdout": sp.DEVNULL, "stderr": sp.PIPE, "stdin": sp.DEVNULL}
    )
    proc = sp.Popen(cmd, **popen_params)
    out, err = proc.communicate()
    proc.stderr.close()
    if proc.returncode:
        logger(message="MoviePy - Command returned an error")
        raise IOError(err.decode("utf8"))
    else:
        logger(message="MoviePy - Command successful")
    del proc
subprocess_call(cmd=['unset', '-background', 'transparent', '-fill', 'white', '-font', 'Liberation-Mono', '-pointsize', '25', '-size', '640x480', '-gravity', 'center', 'caption:@/tmp/tmp6pdbi5v3.txt', '-type', 'truecolormatte', 'PNG32:/tmp/tmpkd0efulh.png'], logger=None)

{state={'bars': OrderedDict()}, stored={}, logs=[], log_indent=0, ignored_bars=None, logged_bars='all', min_time_interval=0, ignore_bars_under=0}

{state={'bars': OrderedDict(), 'message': 'MoviePy - Running:\n>>> unset -background transparent -fill white -font Liberation-Mono -pointsize 25 -size 640x480 -gravity center caption:@/tmp/tmp6pdbi5v3.txt -type truecolormatte PNG32:/tmp/tmpkd0efulh.png'}, stored={}, logs=[], log_indent=0, ignored_bars=None, logged_bars='all', min_time_interval=0, ignore_bars_under=0}


logger(message="MoviePy - Running:\n>>> " + " ".join(cmd))

{state={'bars': OrderedDict(), 'message': 'MoviePy - Running:\n>>> unset -background transparent -fill white -font Liberation-Mono -pointsize 25 -size 640x480 -gravity center caption:@/tmp/tmp6pdbi5v3.txt -type truecolormatte PNG32:/tmp/tmpkd0efulh.png'}, stored={}, logs=[], log_indent=0, ignored_bars=None, logged_bars='all', min_time_interval=0, ignore_bars_under=0}


def __del__(self):
        self.close()
__del__(self=<moviepy.audio.io.readers.FFMPEG_AudioReader object at 0x7f8bd103ec10>, self.bitrate=None, self.buffer=array([[ 0.25909424,  0.11651611],       [ 0.26321411,  0.12841797],       [ 0.25817871,  0.13800049],       ...,       [-0.13201904,  0.03997803],       [-0.14248657,  0.03668213],       [-0.14907837,  0.03515625]]), self.buffer_startframe=0, self.buffersize=44101, self.codec='pcm_s16le', self.duration=1.0, self.filename='media/big_buck_bunny_432_433.webm', self.format='s16le', self.fps=44100, self.infos={'video_found': True, 'audio_found': True, 'metadata': {'encoder': 'Lavf57.25.100'}, 'inputs': [{'streams': [{'input_number': 0, 'stream_number': 0, 'stream_type': 'video', 'language': None, 'default': True, 'size': [1280, 720], 'bitrate': None, 'fps': 24.0}, {'input_number': 0, 'stream_number': 1, 'stream_type': 'audio', 'language': None, 'default': True, 'fps': 44100, 'bitrate': None}], 'input_number': 0}], 'duration': 1.0, 'bitrate': 688, 'start': 0.0, 'default_video_input_number': 0, 'default_video_stream_number': 0, 'video_size': [1280, 720], 'video_bitrate': None, 'video_fps': 24.0, 'default_audio_input_number': 0, 'default_audio_stream_number': 1, 'audio_fps': 44100, 'audio_bitrate': None, 'video_n_frames': 24, 'video_duration': 1.0}, self.n_frames=44100, self.nbytes=2, self.nchannels=2, self.pos=44101, self.proc=<Popen: returncode: None args: ['/local/rcs/XXX/miniforge3/envs/Zulko+mov...>)


def test_save_frame(util, with_mask, t, mask_color, frames):
    filename = os.path.join(util.TMP_DIR, "moviepy_VideoClip_save_frame.png")
    if os.path.isfile(filename):
        try:
            os.remove(filename)
        except PermissionError:
            pass
    width, height = (len(frames[0][0]), len(frames[0]))
    clip = BitmapClip(frames, fps=1)
    if with_mask:
        mask = ColorClip(color=mask_color, is_mask=True, size=(width, height))
        clip = clip.with_mask(mask)
    clip.save_frame(filename, t)
    t = int(convert_to_seconds(t))
    e_r, e_g, e_b = BitmapClip.DEFAULT_COLOR_DICT[frames[t][0][0]]
    im = Image.open(filename, mode="r")
    assert im.width == width
    assert im.height == height
    for i in range(im.width):
        for j in range(im.height):
            rgba = im.getpixel((i, j))
            if len(rgba) == 4:
                r, g, b, a = rgba
            else:
                r, g, b = rgba
            assert r == e_r
            assert g == e_g
            assert b == e_b
            if with_mask:
                assert round(a / 254, 2) == mask_color
test_save_frame(util=<class 'tests.conftest.util.<locals>.MoviepyTestUtils'>, with_mask=False, t=0, mask_color=0, frames=[['RR', 'RR'], ['GG', 'GG'], ['BB', 'BB']])

<PIL.PngImagePlugin.PngImageFile image mode=RGB size=2x2 at 0x7F8BD103EC40>


width, height = (len(frames[0][0]), len(frames[0]))


def filter(get_frame, t):
        angle = get_angle(t)
        im = get_frame(t)
        if unit == "rad":
            angle = math.degrees(angle)
        angle %= 360
        if not center and not translate and not bg_color:
            if (angle == 0) and expand:
                return im
            if (angle == 90) and expand:
                transpose = [1, 0] if len(im.shape) == 2 else [1, 0, 2]
                return np.transpose(im, axes=transpose)[::-1]
            elif (angle == 270) and expand:
                transpose = [1, 0] if len(im.shape) == 2 else [1, 0, 2]
                return np.transpose(im, axes=transpose)[:, ::-1]
            elif (angle == 180) and expand:
                return im[::-1, ::-1]
        if not Image:
            raise ValueError(
                'Without "Pillow" installed, only angles that are a multiple of 90'
                " without centering, translation and background color transformations"
                ' are supported, please install "Pillow" with `pip install pillow`'
            )
        kwargs, _locals = ({}, locals())
        for PIL_rotate_kw_name, (
            kw_name,
            supported,
            min_version,
        ) in PIL_rotate_kwargs_supported.items():
            kw_value = _locals[kw_name]
            if supported:
                kwargs[PIL_rotate_kw_name] = kw_value
            else:
                if kw_value is not None:
                    warnings.warn(
                        f"rotate '{kw_name}' argument is not supported"
                        " by your Pillow version and is being ignored. Minimum"
                        " Pillow version required:"
                        f" v{'.'.join(str(n) for n in min_version)}",
                        UserWarning,
                    )
        if im.dtype == "float64":
            a = 255.0
        else:
            a = 1
        return (
            np.array(
                Image.fromarray(np.array(a * im).astype(np.uint8)).rotate(
                    angle, expand=expand, resample=resample, **kwargs
                )
            )
            / a
        )
filter(get_frame=<bound method Clip.get_frame of <moviepy.video.VideoClip.BitmapClip object at 0x7f8bc4938070>>, t=0, bg_color=None, center=None, expand=True, get_angle=<function rotate.<locals>.<lambda> at 0x7f8bce85de50>, resample=3, translate=None, unit='deg')


def test_write_gif(util, clip_class, opt, loop, with_mask, pixel_format):
    filename = os.path.join(util.TMP_DIR, "moviepy_write_gif.gif")
    if os.path.isfile(filename):
        try:
            os.remove(filename)
        except PermissionError:
            pass
    fps = 10
    if clip_class == "BitmapClip":
        original_clip = BitmapClip([["R"], ["G"], ["B"]], fps=fps).with_duration(0.3)
    else:
        original_clip = concatenate_videoclips(
            [
                ColorClip(
                    (1, 1),
                    color=color,
                )
                .with_duration(0.1)
                .with_fps(fps)
                for color in [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
            ]
        )
    if with_mask:
        original_clip = original_clip.with_mask(
            ColorClip((1, 1), color=1, is_mask=True).with_fps(fps).with_duration(0.3)
        )
    kwargs = {}
    if pixel_format is not None:
        kwargs["pixel_format"] = pixel_format
    write_gif(
        original_clip,
        filename,
        fps=fps,
        with_mask=with_mask,
        program="ffmpeg",
        logger=None,
        opt=opt,
        loop=loop,
        **kwargs,
    )
    if pixel_format != "invalid":
        final_clip = VideoFileClip(filename)
        r, g, b = final_clip.get_frame(0)[0][0]
        assert r == 252
        assert g == 0
        assert b == 0
        r, g, b = final_clip.get_frame(0.1)[0][0]
        assert r == 0
        assert g == 252
        assert b == 0
        r, g, b = final_clip.get_frame(0.2)[0][0]
        assert r == 0
        assert g == 0
        assert b == 255
        assert final_clip.duration == (loop or 1) * round(original_clip.duration, 6)
test_write_gif(util=<class 'tests.conftest.util.<locals>.MoviepyTestUtils'>, clip_class='BitmapClip', opt=False, loop=None, with_mask=False, pixel_format='invalid')


def test_freeze(t, freeze_duration, total_duration, padding_end, output_frames):
    input_frames = ["R", "G", "B"]
    clip_duration = len(input_frames)
    clip = BitmapClip([list(color) for color in input_frames], fps=1).with_duration(
        clip_duration
    )
    possible_kwargs = {
        "t": t,
        "freeze_duration": freeze_duration,
        "total_duration": total_duration,
        "padding_end": padding_end,
    }
    kwargs = {
        kw_name: kw_value
        for kw_name, kw_value in possible_kwargs.items()
        if kw_value is not None
    }
    if hasattr(output_frames, "__traceback__"):
        with pytest.raises(output_frames):
            freeze(clip, **kwargs)
        return
    else:
        freezed_clip = freeze(clip, **kwargs)
    expected_freeze_duration = (
        freeze_duration
        if freeze_duration is not None
        else total_duration - clip_duration
    )
    assert freezed_clip.duration == clip_duration + expected_freeze_duration
    for i, color in enumerate(freezed_clip.iter_frames()):
        expected_color = list(BitmapClip.DEFAULT_COLOR_DICT[output_frames[i]])
        assert list(color[0][0]) == expected_color
test_freeze(t=None, freeze_duration=1, total_duration=None, padding_end=None, output_frames=['R', 'R', 'G', 'B'])

{'t': None, 'freeze_duration': 1, 'total_duration': None, 'padding_end': None}

{start=0, end=4, duration=4, memoize=False, memoized_t=None, memoized_frame=None, mask=None, audio=None, relative_pos=False, layer=0, size=(1, 1), is_mask=False, has_constant_size=True, timings=array([0, 1, 4]), start_times=array([0, 1]), fps=1}


clip = BitmapClip([list(color) for color in input_frames], fps=1).with_duration(


{'t': None, 'freeze_duration': 1, 'total_duration': None, 'padding_end': None}


def test_margin(ClipClass, margin_size, margins, color, expected_result):
    if ClipClass is BitmapClip:
        clip = BitmapClip([["RRR", "RRR"], ["RRR", "RRR"]], fps=1)
    else:
        clip = ColorClip(color=(255, 0, 0), size=(3, 2), duration=2).with_fps(1)
    if color is None:
        color = (0, 0, 0)
    if margins is None:
        margins = [0, 0, 0, 0]
    left, right, top, bottom = margins
    new_clip = margin(
        clip,
        margin_size=margin_size,
        left=left,
        right=right,
        top=top,
        bottom=bottom,
        color=color,
    )
    assert new_clip == BitmapClip(expected_result, fps=1)
test_margin(ClipClass=<class 'moviepy.video.VideoClip.ColorClip'>, margin_size=None, margins=None, color=None, expected_result=[['RRR', 'RRR'], ['RRR', 'RRR']])

{start=0, end=2, duration=2, memoize=False, memoized_t=None, memoized_frame=None, mask=None, audio=None, relative_pos=False, layer=0, is_mask=False, has_constant_size=True, size=(3, 2), img=array([[[255,   0,   0],        [255,   0,   0],        [255,   0,   0]],       [[255,   0,   0],        [255,   0,   0],        [255,   0,   0]]]), fps=1}


def test_mask_and(image_from, duration, color, mask_color, expected_color):
    clip_size = tuple(random.randint(3, 10) for i in range(2))
    if duration == "random":
        duration = round(random.uniform(0, 0.5), 2)
    clip = ColorClip(color=color, size=clip_size).with_duration(duration)
    mask_clip = ColorClip(color=mask_color, size=clip.size)
    masked_clip = mask_and(
        clip, mask_clip if image_from == "ImageClip" else mask_clip.get_frame(0)
    )
    assert masked_clip.duration == clip.duration
    assert np.array_equal(masked_clip.get_frame(0)[0][0], np.array(expected_color))
    color_frame, mask_color_frame = (np.array([[color]]), np.array([[mask_color]]))
    clip = VideoClip(lambda t: color_frame).with_duration(duration)
    mask_clip = VideoClip(lambda t: mask_color_frame).with_duration(duration)
    masked_clip = mask_and(clip, mask_clip)
    assert np.array_equal(masked_clip.get_frame(0)[0][0], np.array(expected_color))
test_mask_and(image_from='np.ndarray', duration=None, color=(0, 0, 0), mask_color=(255, 255, 255), expected_color=(0, 0, 0))

{start=0, end=None, duration=None, memoize=False, memoized_t=None, memoized_frame=None, mask=None, audio=None, relative_pos=False, layer=0, size=(1, 1), is_mask=False, has_constant_size=True}


mask_clip = ColorClip(color=mask_color, size=clip.size)


def get_reporting_config() -> Dict[str, Any]:
    reporting_config: Dict[str, Any] = {"consent": False}
    try:
        if not os.path.exists(REPORTING_CONFIG_FILE_PATH):
            client_id = str(uuid.uuid4())
            reporting_config["client_id"] = client_id
            reporting_config = save_reporting_config(True, client_id)
        else:
            with open(REPORTING_CONFIG_FILE_PATH, "r") as ifp:
                reporting_config = json.load(ifp)
        reporting_config["machine_id"] = reporting_config["client_id"]
        if (
            reporting_config.get("username") is not None
            and reporting_config["client_id"] != reporting_config["username"]
        ):
            reporting_config["client_id"] = reporting_config["username"]
    except Exception:
        pass
    return reporting_config
get_reporting_config()

<_io.TextIOWrapper name='/home/XXX/.activeloop/reporting_config.json' mode='r' encoding='UTF-8'>


def version_compare(v1, v2):
    arr1 = v1.split(".")
    arr2 = v2.split(".")
    n = len(arr1)
    m = len(arr2)
    arr1 = [int(i) for i in arr1]
    arr2 = [int(i) for i in arr2]
    if n > m:
        for i in range(m, n):
            arr2.append(0)
    elif m > n:
        for i in range(n, m):
            arr1.append(0)
    for i in range(len(arr1)):
        if arr1[i] > arr2[i]:
            return 1
        elif arr2[i] > arr1[i]:
            return -1
    return 0
version_compare(v1='3.8.18', v2='3.8.27')


def parse_access_method(access_method: str):
    num_workers = 0
    scheduler = "threaded"
    download = access_method.startswith("download")
    local = access_method.startswith("local")
    if download or local:
        split = access_method.split(":")
        if len(split) == 1:
            split.extend(("threaded", "0"))
        elif len(split) == 2:
            split.append("threaded" if split[1].isnumeric() else "0")
        elif len(split) >= 3:
            num_integers = sum(1 for i in split if i.isnumeric())
            if num_integers != 1 or len(split) > 3:
                raise ValueError(
                    "Invalid access_method format. Expected format is one of the following: {download, download:scheduler, download:num_workers, download:scheduler:num_workers, download:num_workers:scheduler}"
                )
        access_method = "download" if download else "local"
        num_worker_index = 1 if split[1].isnumeric() else 2
        scheduler_index = 3 - num_worker_index
        num_workers = int(split[num_worker_index])
        scheduler = split[scheduler_index]
    return access_method, num_workers, scheduler
parse_access_method(access_method='download')


def __getstate__(self) -> Dict[str, Any]:
        d = super().__getstate__()
        d["tensors"] = self.tensors.copy()
        d["groups"] = self.groups.copy()
        d["tensor_names"] = self.tensor_names.copy()
        d["hidden_tensors"] = self.hidden_tensors.copy()
        d["default_index"] = self.default_index.copy()
        return d
__getstate__(self=<deeplake.core.meta.dataset_meta.DatasetMeta object at 0x7f6b79b0dd90>, __class__=<class 'deeplake.core.meta.dataset_meta.DatasetMeta'>, self.default_index=[{'start': None, 'stop': None, 'step': None}], self.groups=[], self.hidden_tensors=[], self.is_dirty=False, self.tensor_names={}, self.tensors=[], self.version='3.8.18')

{'version': '3.8.18', 'tensors': [], 'groups': [], 'tensor_names': {}, 'hidden_tensors': []}

{'version': '3.8.18', 'tensors': [], 'groups': [], 'tensor_names': {}, 'hidden_tensors': [], 'default_index': [{'start': None, 'stop': None, 'step': None}]}


{'version': '3.8.18', 'tensors': [], 'groups': [], 'tensor_names': {}, 'hidden_tensors': []}


{'version': '3.8.18', 'tensors': [], 'groups': [], 'tensor_names': {}, 'hidden_tensors': [], 'default_index': [{'start': None, 'stop': None, 'step': None}]}


def _validate_links(links: dict):
    if not isinstance(links, dict):
        raise InvalidTensorLinkError()
    allowed_keys = ("extend", "update", "flatten_sequence")
    for out_tensor, args in links.items():
        if not isinstance(out_tensor, str):
            raise InvalidTensorLinkError()
        if not isinstance(args, dict):
            raise InvalidTensorLinkError()
        if "extend" not in args:
            raise InvalidTensorLinkError(
                f"extend transform not specified for link {out_tensor}"
            )
        if "flatten_sequence" not in args:
            raise InvalidTensorLinkError(
                f"flatten_sequence arg not specified for link {out_tensor}"
            )
        try:
            get_link_transform(args["extend"])
        except KeyError:
            raise InvalidTensorLinkError(f"Invalid extend transform: {args['extend']}")
        if "update" in args:
            try:
                get_link_transform(args["update"])
            except KeyError:
                raise InvalidTensorLinkError(
                    f"Invalid update transform: {args['extend']}"
                )
        for k in args:
            if k not in allowed_keys:
                raise InvalidTensorLinkError(f"Invalid key in link meta: {k}")
_validate_links(links={})


def add_tensor(self, name, key, hidden=False):
        if key not in self.tensors:
            self.tensor_names[name] = key
            self.tensors.append(key)
            if hidden:
                self.hidden_tensors.append(key)
            self.is_dirty = True
add_tensor(self=<deeplake.core.meta.dataset_meta.DatasetMeta object at 0x7f6b79b0dd90>, name='image', key='image', hidden=False, self.default_index=[{'start': None, 'stop': None, 'step': None}], self.groups=[], self.hidden_tensors=[], self.is_dirty=False, self.tensor_names={}, self.tensors=[], self.version='3.8.18')


def serialize_chunkids(version: str, arr: np.ndarray) -> memoryview:
    len_version = len(version)
    write_dtype = version_compare(version, "2.7.6") >= 0
    flatbuff = bytearray(1 + int(write_dtype) + len_version + arr.nbytes)
    len_version = len(version)
    flatbuff[0] = len_version
    flatbuff[1 : 1 + len_version] = version.encode("ascii")
    offset = 1 + len_version
    if write_dtype:
        dtype = arr.dtype
        num_bytes = int(dtype.itemsize)
        flatbuff[offset] = num_bytes
        offset += 1
    flatbuff[offset : offset + arr.nbytes] = arr.tobytes()
    offset += arr.nbytes
    return memoryview(flatbuff)
serialize_chunkids(version='3.8.18', arr=array([], shape=(0, 2), dtype=uint64))


def set_dtype(self, dtype: np.dtype):
        if self.dtype is not None:
            raise ValueError(
                f"Tensor meta already has a dtype ({self.dtype}). Incoming: {dtype.name}."
            )
        self.dtype = dtype.name
        self.typestr = dtype.str
        self.is_dirty = True
set_dtype(self=<deeplake.core.meta.tensor_meta.TensorMeta object at 0x7f6b79b0dca0>, dtype=dtype('float64'), self._required_meta_keys=('htype', 'min_shape', 'max_shape', 'length', 'hidden', 'dtype', 'sample_compression', 'chunk_compression', 'typestr', 'max_chunk_size', 'tiling_threshold', 'is_sequence', 'is_link', 'links', 'verify'), self.chunk_compression=None, self.dtype=None, self.hidden=False, self.htype='generic', self.is_dirty=True, self.is_link=False, self.is_sequence=False, self.length=0, self.links={'_image_shape': {'extend': 'extend_shape', 'flatten_sequence': True, 'update': 'update_shape'}, '_image_id': {'extend': 'extend_id', 'flatten_sequence': False}}, self.max_chunk_size=2000000, self.max_shape=[], self.min_shape=[], self.name='image', self.sample_compression=None, self.tiling_threshold=None, self.typestr=None, self.verify=True, self.version='3.8.18')


def _create_new_chunk(self, register=True, row: Optional[int] = None) -> BaseChunk:
        chunk_id = self.chunk_id_encoder.generate_chunk_id(register=register, row=row)
        chunk = self.chunk_class(*self.chunk_args)
        chunk_name = ChunkIdEncoder.name_from_id(chunk_id)
        chunk_key = get_chunk_key(self.key, chunk_name, self.commit_id)
        if self.commit_chunk_map is not None:
            self.commit_chunk_map.add(chunk_name)
        chunk.key = chunk_key
        chunk.id = chunk_id
        chunk._update_tensor_meta_length = register
        if self.active_appended_chunk is not None:
            self.write_chunk_to_storage(self.active_appended_chunk)
        self.active_appended_chunk = chunk
        return chunk
_create_new_chunk(self=<deeplake.core.chunk_engine.ChunkEngine object at 0x7f6b79b0d340>, register=False, row=None, self._active_appended_chunk=None, self._active_updated_chunk=None, self._all_chunk_engines=None, self._chunk_args=None, self._chunk_compression=None, self._chunk_id_encoder=<deeplake.core.meta.encode.chunk_id.ChunkIdEncoder object at 0x7f6b79b0d490>, self._chunk_id_encoder_commit_id='firstdbf9474d461a19e9333c2fd19b46115348f', self._commit_chunk_map=None, self._commit_chunk_map_commit_id=None, self._commit_diff=None, self._commit_diff_commit_id=None, self._hash_label_map=OrderedDict(), self._info=None, self._info_commit_id=None, self._is_temp_label_tensor=False, self._meta_cache=None, self._num_samples_per_chunk=None, self._numpy_extend_optimization_enabled=True, self._pad_encoder=None, self._pad_encoder_commit_id=None, self._sample_compression=None, self._sequence_encoder=None, self._sequence_encoder_commit_id=None, self._tensor_meta=<deeplake.core.meta.tensor_meta.TensorMeta object at 0x7f6b79b0dca0>, self._tensor_meta_commit_id='firstdbf9474d461a19e9333c2fd19b46115348f', self._tile_encoder=None, self._tile_encoder_commit_id=None, self.base_storage=<deeplake.core.storage.memory.MemoryProvider object at 0x7f6b79af7c10>, self.cache=<deeplake.core.storage.lru_cache.LRUCache object at 0x7f6b79af7fa0>, self.cache_enabled=True, self.cache_range=range(0, 0), self.cached_data=None, self.chunk_class=<class 'deeplake.core.chunk.uncompressed_chunk.UncompressedChunk'>, self.compression=None, self.key='image', self.link_creds=None, self.name='image', self.start_chunk=None, self.version_state={'branch': 'main', 'branch_commit_map': {'main': 'firstdbf9474d461a19e9333c2fd19b46115348f'}, 'commit_node_map': {'firstdbf9474d461a19e9333c2fd19b46115348f': Commit : firstdbf9474d461a19e9333c2fd19b46115348f (main) Author : NoneTime   : Message: None}, 'commit_id': 'firstdbf9474d461a19e9333c2fd19b46115348f', 'commit_node': Commit : firstdbf9474d461a19e9333c2fd19b46115348f (main) Author : NoneTime   : Message: None, 'full_tensors': {'image': Tensor(key='image'), '_image_shape': Tensor(key='_image_shape'), '_image_id': Tensor(key='_image_id')}, 'tensor_names': {'image': 'image', '_image_shape': '_image_shape', '_image_id': '_image_id'}, 'meta': <deeplake.core.meta.dataset_meta.DatasetMeta object at 0x7f6b79b0dd90>}, self.write_initialization_done=True)

<deeplake.core.chunk.uncompressed_chunk.UncompressedChunk object at 0x7f6b79b0d3a0>

[1000000, 2000000, 16000000, <deeplake.core.meta.tensor_meta.TensorMeta object at 0x7f6b79b0dca0>, None]

{is_dirty=True, _data_bytes=bytearray(b''), version='3.8.18', min_chunk_size=1000000, max_chunk_size=2000000, tiling_threshold=16000000, tensor_meta=<deeplake.core.meta.tensor_meta.TensorMeta object at 0x7f6b79b0dca0>, num_dims=None, is_text_like=False, compression=None, is_byte_compression=False, is_image_compression=False, is_video_compression=False, is_convert_candidate=False, shapes_encoder=<deeplake.core.meta.encode.shape.ShapeEncoder object at 0x7f6b79b0dd30>, byte_positions_encoder=<deeplake.core.meta.encode.byte_positions.BytePositionsEncoder object at 0x7f6b79b0dd00>, decompressed_samples=None, decompressed_bytes=None, _update_tensor_meta_length=True, _item_size=None, _sample_size=None, write_initialization_done=False, id=None, key=None}

{is_dirty=True, _data_bytes=bytearray(b''), version='3.8.18', min_chunk_size=1000000, max_chunk_size=2000000, tiling_threshold=16000000, tensor_meta=<deeplake.core.meta.tensor_meta.TensorMeta object at 0x7f6b79b0dca0>, num_dims=None, is_text_like=False, compression=None, is_byte_compression=False, is_image_compression=False, is_video_compression=False, is_convert_candidate=False, shapes_encoder=<deeplake.core.meta.encode.shape.ShapeEncoder object at 0x7f6b79b0dd30>, byte_positions_encoder=<deeplake.core.meta.encode.byte_positions.BytePositionsEncoder object at 0x7f6b79b0dd00>, decompressed_samples=None, decompressed_bytes=None, _update_tensor_meta_length=True, _item_size=None, _sample_size=None, write_initialization_done=False, id=None, key='image/chunks/3d613c80329b4f9e'}

{is_dirty=True, _data_bytes=bytearray(b''), version='3.8.18', min_chunk_size=1000000, max_chunk_size=2000000, tiling_threshold=16000000, tensor_meta=<deeplake.core.meta.tensor_meta.TensorMeta object at 0x7f6b79b0dca0>, num_dims=None, is_text_like=False, compression=None, is_byte_compression=False, is_image_compression=False, is_video_compression=False, is_convert_candidate=False, shapes_encoder=<deeplake.core.meta.encode.shape.ShapeEncoder object at 0x7f6b79b0dd30>, byte_positions_encoder=<deeplake.core.meta.encode.byte_positions.BytePositionsEncoder object at 0x7f6b79b0dd00>, decompressed_samples=None, decompressed_bytes=None, _update_tensor_meta_length=True, _item_size=None, _sample_size=None, write_initialization_done=False, id=4422882830357057438, key='image/chunks/3d613c80329b4f9e'}

{is_dirty=True, _data_bytes=bytearray(b''), version='3.8.18', min_chunk_size=1000000, max_chunk_size=2000000, tiling_threshold=16000000, tensor_meta=<deeplake.core.meta.tensor_meta.TensorMeta object at 0x7f6b79b0dca0>, num_dims=None, is_text_like=False, compression=None, is_byte_compression=False, is_image_compression=False, is_video_compression=False, is_convert_candidate=False, shapes_encoder=<deeplake.core.meta.encode.shape.ShapeEncoder object at 0x7f6b79b0dd30>, byte_positions_encoder=<deeplake.core.meta.encode.byte_positions.BytePositionsEncoder object at 0x7f6b79b0dd00>, decompressed_samples=None, decompressed_bytes=None, _update_tensor_meta_length=False, _item_size=None, _sample_size=None, write_initialization_done=False, id=4422882830357057438, key='image/chunks/3d613c80329b4f9e'}


chunk_name = ChunkIdEncoder.name_from_id(chunk_id)  # type: ignore


def update_shape_interval(self, shape: Sequence[int]):
        initial_min_shape = None if self.min_shape is None else self.min_shape.copy()
        initial_max_shape = None if self.max_shape is None else self.max_shape.copy()
        if not self.min_shape:
            self.min_shape = list(shape)
            self.max_shape = list(shape)
        else:
            expected_dims = len(self.min_shape)
            if len(shape) != expected_dims:
                raise TensorInvalidSampleShapeError(shape, len(self.min_shape))
            for i, dim in enumerate(shape):
                self.min_shape[i] = min(dim, self.min_shape[i])
                self.max_shape[i] = max(dim, self.max_shape[i])
        if initial_min_shape != self.min_shape or initial_max_shape != self.max_shape:
            self.is_dirty = True
update_shape_interval(self=<deeplake.core.meta.tensor_meta.TensorMeta object at 0x7f6b79b0dca0>, shape=(1024, 1024), self._required_meta_keys=('htype', 'min_shape', 'max_shape', 'length', 'hidden', 'dtype', 'sample_compression', 'chunk_compression', 'typestr', 'max_chunk_size', 'tiling_threshold', 'is_sequence', 'is_link', 'links', 'verify'), self.chunk_compression=None, self.dtype='float64', self.hidden=False, self.htype='generic', self.is_dirty=True, self.is_link=False, self.is_sequence=False, self.length=0, self.links={'_image_shape': {'extend': 'extend_shape', 'flatten_sequence': True, 'update': 'update_shape'}, '_image_id': {'extend': 'extend_id', 'flatten_sequence': False}}, self.max_chunk_size=2000000, self.max_shape=[], self.min_shape=[], self.name='image', self.sample_compression=None, self.tiling_threshold=None, self.typestr='<f8', self.verify=True, self.version='3.8.18')


def _get_new_player_rack_list(self, num_players):
        player_rack_list = []
        for _ in range(num_players):
            this_rack = []
            for _ in range(config.PLAYER_RACK_SIZE):
                this_tile = self._draw_random_tile()
                this_rack.append(this_tile)
            player_rack_list.append(this_rack)
        return player_rack_list
_get_new_player_rack_list(self=REPR FAILED, num_players=4, self.tile_bag=[*, *, A, A, A, A, A, A, A, A, A, B, B, C, C, D, D, D, D, E, E, E, E, E, E, E, E, E, E, E, E, F, F, G, G, G, H, H, I, I, I, I, I, I, I, I, I, J, K, L, L, L, L, M, M, N, N, N, N, N, N, O, O, O, O, O, O, O, O, P, P, Q, R, R, R, R, R, R, S, S, S, S, T, T, T, T, T, T, U, U, U, U, V, V, W, W, X, Y, Y, Z])


def _draw_random_tile(self):
        random_index = random.randrange(0, len(self.tile_bag))
        selected_tile = self.tile_bag.pop(random_index)
        return selected_tile
_draw_random_tile(self=REPR FAILED, self.tile_bag=[*, *, A, A, A, A, A, A, A, A, A, B, B, C, C, D, D, D, D, E, E, E, E, E, E, E, E, E, E, E, E, F, F, G, G, G, H, H, I, I, I, I, I, I, I, I, I, J, K, L, L, L, L, M, M, N, N, N, N, N, N, O, O, O, O, O, O, O, O, P, P, Q, R, R, R, R, R, R, S, S, S, S, T, T, T, T, T, T, U, U, U, U, V, V, W, W, X, Y, Y, Z])


def initialize_new_board_square_dict():
    initial_board_square_dict = {}
    for column in config.LETTER_CODE_DICT:
        for row in range(1, config.BOARD_NUM_ROWS + 1):
            location = (column, row)
            word_multiplier = config.WORD_SCORE_MULT_LOCATION_DICT.get(
                location,
                1
            )
            letter_multiplier = config.LETTER_SCORE_MULT_LOCATION_DICT.get(
                location,
                1
            )
            initial_board_square_dict[location] = BoardSquare(
                tile=None,
                word_multiplier=word_multiplier,
                letter_multiplier=letter_multiplier
            )
    return initial_board_square_dict
initialize_new_board_square_dict()


def move_is_sublist(letter_list_1, letter_list_2):
    letter_counter_1 = collections.Counter(letter_list_1)
    letter_counter_2 = collections.Counter(letter_list_2)
    for letter, cardinality in letter_counter_1.items():
        if cardinality > letter_counter_2[letter]:
            return False
    return True
move_is_sublist(letter_list_1=[1, 2, 3], letter_list_2=[1, 2, 3, 4])


def get_word_letter_location_set(word, start_location, is_vertical_move):
    letter_location_set = set()
    next_location_func = get_next_location_function(
        use_positive_seek=True,
        use_vertical_words=is_vertical_move
    )
    current_location = start_location
    word_iterator = iter(word)
    for character in word_iterator:
        if character == '(':
            character = next(word_iterator, None)
            while character != ')':
                current_location = next_location_func(current_location)
                character = next(word_iterator, None)
            character = next(word_iterator, None)
        if character:
            letter_location_set.add((character, current_location))
            current_location = next_location_func(current_location)
    return letter_location_set
get_word_letter_location_set(word='BAKER', start_location=('h', 8), is_vertical_move=False)

<function get_next_location_function.<locals>.<lambda> at 0x7feb6dd68f70>


def next_player_move(self, letter_location_set):
        player_to_move_id, player_rack = get_current_player_data(
            self.move_number,
            self.player_rack_list
        )
        is_legal_move = move_is_legal(self.board,
                                      self.move_number,
                                      letter_location_set,
                                      player_rack)
        if is_legal_move:
            if move_successfully_challenged():
                letter_location_set = set()
            for move_letter, board_location in letter_location_set:
                tile_index = get_rack_tile_index(player_rack, move_letter)
                tile_obj = player_rack.pop(tile_index)
                self.board[board_location] = tile_obj
            move_score = score_move(letter_location_set, self.board)
            self.player_score_list_list[player_to_move_id].append(move_score)
            self._refill_player_rack(player_rack)
            self._cancel_bonus_squares(letter_location_set)
            if len(player_rack) == 0 and len(self.tile_bag) == 0:
                last_move_score_list = score_end_of_game(self.player_rack_list,
                                                         player_to_move_id)
                for i, last_move_score in enumerate(last_move_score_list):
                    self.player_score_list_list[i].append(last_move_score)
                conclude_game(self.player_score_list_list)
            self.move_number += 1
            return True
        else:
            return False
next_player_move(self=  abcdefghijklmno1 _______________2 _______________3 _______________4 _______________5 _______________6 _______________7 _______________8 _______★_______9 _______________10_______________11_______________12_______________13_______________14_______________15_______________[[Q, E, O, S, G, H, E, B, A, K, E, R], [R, Z, L, A, U, L, A], [W, C, E, T, N, E, E], [T, R, O, B, T, N, N]]Moves played: 0Player 1's move72 tiles remain in bagPlayer 1: 0Player 2: 0Player 3: 0Player 4: 0, letter_location_set={('K', ('j', 8)), ('B', ('h', 8)), ('A', ('i', 8)), ('E', ('k', 8)), ('R', ('l', 8))}, self.board=  abcdefghijklmno1 _______________2 _______________3 _______________4 _______________5 _______________6 _______________7 _______________8 _______★_______9 _______________10_______________11_______________12_______________13_______________14_______________15_______________, self.move_number=0, self.player_rack_list=[[Q, E, O, S, G, H, E, B, A, K, E, R], [R, Z, L, A, U, L, A], [W, C, E, T, N, E, E], [T, R, O, B, T, N, N]], self.player_score_list_list=[[], [], [], []], self.tile_bag=[*, *, A, A, A, A, A, A, A, B, C, D, D, D, D, E, E, E, E, E, E, E, F, F, G, G, H, I, I, I, I, I, I, I, I, I, J, K, L, L, M, M, N, N, N, O, O, O, O, O, O, P, P, R, R, R, R, S, S, S, T, T, T, U, U, U, V, V, W, X, Y, Y])


def move_is_legal(board, move_number, letter_location_set, player_rack=None):
    letter_list = [letter for letter, _ in letter_location_set]
    location_set = set(location for _, location in letter_location_set)
    return_bool = (
        move_is_rack_size_or_less(location_set) and
        move_does_not_misalign_tiles(location_set) and
        move_is_not_out_of_bounds(location_set) and
        all_move_tiles_connected(board, location_set) and
        move_does_not_stack_tiles(letter_list, location_set) and
        move_does_not_cover_tiles(board, location_set) and
        move_touches_tile(move_number, board, location_set)
    )
    if player_rack:
        player_rack_letter_list = [tile.letter for tile in player_rack]
        return_bool = return_bool and move_is_sublist(letter_list,
                                                      player_rack_letter_list)
    return return_bool
move_is_legal(board=  abcdefghijklmno1 _______________2 _______________3 _______________4 _______________5 _______________6 _______________7 _______________8 _______★_______9 _______________10_______________11_______________12_______________13_______________14_______________15_______________, move_number=0, letter_location_set={('K', ('j', 8)), ('B', ('h', 8)), ('A', ('i', 8)), ('E', ('k', 8)), ('R', ('l', 8))}, player_rack=[Q, E, O, S, G, H, E, B, A, K, E, R])


def all_move_tiles_connected(board, location_set):
    column_list = [column for column, _ in location_set]
    row_list = [row for _, row in location_set]
    move_is_vertical = (len(set(column_list)) == 1)
    if move_is_vertical:
        this_column = column_list[0]
        for this_row in range(min(row_list), max(row_list) + 1):
            this_tile = board[(this_column, this_row)]
            if not (this_tile or (this_column, this_row) in location_set):
                return False
    else:
        column_range = range(
            config.LETTER_CODE_DICT[min(column_list)],
            config.LETTER_CODE_DICT[max(column_list)] + 1
        )
        this_row = row_list[0]
        for this_column_num in column_range:
            this_column = chr(this_column_num)
            this_tile = board[(this_column, this_row)]
            if not (this_tile or (this_column, this_row) in location_set):
                return False
    return True
all_move_tiles_connected(board=  abcdefghijklmno1 _______________2 _______________3 _______________4 _______________5 _______________6 _______________7 _______________8 _______★_______9 _______________10_______________11_______________12_______________13_______________14_______________15_______________, location_set={('j', 8), ('l', 8), ('h', 8), ('i', 8), ('k', 8)})


def get_word_location_set(board, initial_location, use_vertical_words):
    word_location_set = set()
    for use_positive_seek in [True, False]:
        current_location = initial_location
        current_tile = board[current_location]
        next_location_func = get_next_location_function(use_positive_seek,
                                                        use_vertical_words)
        while current_tile:
            word_location_set.add(current_location)
            current_location = next_location_func(current_location)
            if location_is_out_of_bounds(current_location):
                current_tile = None
            else:
                current_tile = board[current_location]
    if len(word_location_set) > 1:
        return frozenset(word_location_set)
    else:
        return frozenset()
get_word_location_set(board=  abcdefghijklmno1 _______________2 _______________3 _______________4 _______________5 _______________6 _______________7 _______________8 _______BAKER___9 _______________10_______________11_______________12_______________13_______________14_______________15_______________, initial_location=('j', 8), use_vertical_words=True)

<function get_next_location_function.<locals>.<lambda> at 0x7feb6defcdc0>

<function get_next_location_function.<locals>.<lambda> at 0x7feb6d88bdc0>


def get_word_set_total_score(board, word_set, num_move_locations):
    total_score = 0
    word_score = 0
    for word_location_set in word_set:
        word_score = 0
        word_multiplier = 1
        for location in word_location_set:
            square = board.board_square_dict[location]
            word_multiplier *= square.word_multiplier
            word_score += square.tile.point_value * square.letter_multiplier
        word_score *= word_multiplier
        total_score += word_score
    if num_move_locations == config.PLAYER_RACK_SIZE:
        total_score += config.BINGO_SCORE
    return total_score
get_word_set_total_score(board=  abcdefghijklmno1 _______________2 _______________3 _______________4 _______________5 _______________6 _______________7 _______________8 _______BAKER___9 _______________10_______________11_______________12_______________13_______________14_______________15_______________, word_set={frozenset(), frozenset({('h', 8), ('j', 8), ('l', 8), ('i', 8), ('k', 8)})}, num_move_locations=5)


_, player_rack = get_current_player_data(self.move_number,


def requires_crt(reason=None):
    if reason is None:
        reason = "Test requires awscrt to be installed"
    def decorator(func):
        return unittest.skipIf(not HAS_CRT, reason)(func)
    return decorator
requires_crt(reason=None)

<function requires_crt.<locals>.decorator at 0x7fbbe4f994c0>


def _handler(**kwargs):
        module, function_name = full_name.rsplit('.', 1)
        module = import_module(module)
        kwargs.update(parent_kwargs)
        return getattr(module, function_name)(**kwargs)
_handler(kwargs={'class_attributes': {'meta': ResourceMeta('dynamodb', identifiers=[]), 'batch_get_item': <function ResourceFactory._create_action.<locals>.do_action at 0x7fbbe3a924c0>, 'batch_write_item': <function ResourceFactory._create_action.<locals>.do_action at 0x7fbbe3a92550>, 'create_table': <function ResourceFactory._create_action.<locals>.do_action at 0x7fbbe3957820>, 'tables': <property object at 0x7fbbe37534a0>, 'Table': <function ResourceFactory._create_class_partial.<locals>.create_resource at 0x7fbbe3957e50>, 'get_available_subresources': <function ResourceFactory._create_available_subresources_command.<locals>.get_available_subresources at 0x7fbbe3957ee0>}, 'base_classes': [<class 'boto3.resources.base.ServiceResource'>], 'service_context': ServiceContext(service_name='dynamodb', service_model=ServiceModel(dynamodb), service_waiter_model=<boto3.utils.LazyLoadedWaiterModel object at 0x7fbbe3bb2940>, resource_json_definitions=OrderedDict([('Table', OrderedDict([('identifiers', [OrderedDict([('name', 'Name'), ('memberName', 'TableName')])]), ('shape', 'TableDescription'), ('load', OrderedDict([('request', OrderedDict([('operation', 'DescribeTable'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])])), ('path', 'Table')])), ('actions', OrderedDict([('Delete', OrderedDict([('request', OrderedDict([('operation', 'DeleteTable'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('DeleteItem', OrderedDict([('request', OrderedDict([('operation', 'DeleteItem'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('GetItem', OrderedDict([('request', OrderedDict([('operation', 'GetItem'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('PutItem', OrderedDict([('request', OrderedDict([('operation', 'PutItem'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('Query', OrderedDict([('request', OrderedDict([('operation', 'Query'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('Scan', OrderedDict([('request', OrderedDict([('operation', 'Scan'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('Update', OrderedDict([('request', OrderedDict([('operation', 'UpdateTable'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])])), ('resource', OrderedDict([('type', 'Table'), ('identifiers', [OrderedDict([('target', 'Name'), ('source', 'identifier'), ('name', 'Name')])]), ('path', 'TableDescription')]))])), ('UpdateItem', OrderedDict([('request', OrderedDict([('operation', 'UpdateItem'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))]))])), ('waiters', OrderedDict([('Exists', OrderedDict([('waiterName', 'TableExists'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])])), ('NotExists', OrderedDict([('waiterName', 'TableNotExists'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))]))]))])), 'event_name': 'creating-resource-class.dynamodb.ServiceResource'}, full_name='boto3.dynamodb.transform.register_high_level_interface', parent_kwargs={})

{'class_attributes': {'meta': ResourceMeta('dynamodb', identifiers=[]), 'batch_get_item': <function ResourceFactory._create_action.<locals>.do_action at 0x7fbbe3a924c0>, 'batch_write_item': <function ResourceFactory._create_action.<locals>.do_action at 0x7fbbe3a92550>, 'create_table': <function ResourceFactory._create_action.<locals>.do_action at 0x7fbbe3957820>, 'tables': <property object at 0x7fbbe37534a0>, 'Table': <function ResourceFactory._create_class_partial.<locals>.create_resource at 0x7fbbe3957e50>, 'get_available_subresources': <function ResourceFactory._create_available_subresources_command.<locals>.get_available_subresources at 0x7fbbe3957ee0>}, 'base_classes': [<class 'boto3.dynamodb.transform.DynamoDBHighLevelResource'>, <class 'boto3.resources.base.ServiceResource'>], 'service_context': ServiceContext(service_name='dynamodb', service_model=ServiceModel(dynamodb), service_waiter_model=<boto3.utils.LazyLoadedWaiterModel object at 0x7fbbe3bb2940>, resource_json_definitions=OrderedDict([('Table', OrderedDict([('identifiers', [OrderedDict([('name', 'Name'), ('memberName', 'TableName')])]), ('shape', 'TableDescription'), ('load', OrderedDict([('request', OrderedDict([('operation', 'DescribeTable'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])])), ('path', 'Table')])), ('actions', OrderedDict([('Delete', OrderedDict([('request', OrderedDict([('operation', 'DeleteTable'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('DeleteItem', OrderedDict([('request', OrderedDict([('operation', 'DeleteItem'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('GetItem', OrderedDict([('request', OrderedDict([('operation', 'GetItem'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('PutItem', OrderedDict([('request', OrderedDict([('operation', 'PutItem'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('Query', OrderedDict([('request', OrderedDict([('operation', 'Query'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('Scan', OrderedDict([('request', OrderedDict([('operation', 'Scan'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))])), ('Update', OrderedDict([('request', OrderedDict([('operation', 'UpdateTable'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])])), ('resource', OrderedDict([('type', 'Table'), ('identifiers', [OrderedDict([('target', 'Name'), ('source', 'identifier'), ('name', 'Name')])]), ('path', 'TableDescription')]))])), ('UpdateItem', OrderedDict([('request', OrderedDict([('operation', 'UpdateItem'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))]))])), ('waiters', OrderedDict([('Exists', OrderedDict([('waiterName', 'TableExists'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])])), ('NotExists', OrderedDict([('waiterName', 'TableNotExists'), ('params', [OrderedDict([('target', 'TableName'), ('source', 'identifier'), ('name', 'Name')])])]))]))]))])), 'event_name': 'creating-resource-class.dynamodb.ServiceResource'}


def _transform_map(self, model, params, transformation, target_shape):
        if not isinstance(params, collections_abc.Mapping):
            return
        value_model = model.value
        value_shape = value_model.name
        for key, value in params.items():
            if value_shape == target_shape:
                params[key] = transformation(value)
            else:
                self._transform_parameters(
                    value_model, params[key], transformation, target_shape
                )
_transform_map(self=<boto3.dynamodb.transform.ParameterTransformer object at 0x7fbbd84c4a60>, model=<MapShape(ExpressionAttributeNameMap)>, params={'

<bound method TypeSerializer.serialize of <boto3.dynamodb.types.TypeSerializer object at 0x7fbbd84c4a30>>


def test_lexer_single_token(expression, result):
    lexer = MOALexer()
    tokens = tuple(token.type for token in lexer.tokenize(expression))
    assert tokens == result
test_lexer_single_token(expression='1234', result=('INTEGER',))


def INTEGER(self, t):
        t.value = int(t.value)
        return t
INTEGER(self=<moa.frontend.moa.MOALexer object at 0x7f5da3d53640>, t=Token(type='INTEGER', value='1234', lineno=1, index=0, end=4), self._Lexer__set_state=<function Lexer.tokenize.<locals>._set_state at 0x7f5da3e37b80>, self.accept=<function Lexer.tokenize.<locals>._accept at 0x7f5da3e75f70>, self.index=4, self.lineno=1, self.mark=<function Lexer.tokenize.<locals>._mark at 0x7f5da4760b80>, self.reject=<function Lexer.tokenize.<locals>._reject at 0x7f5da3e75ee0>, self.text='1234')

Token(type='INTEGER', value=1234, lineno=1, index=0, end=4)


def suggest_type(full_text, text_before_cursor):
    word_before_cursor = last_word(text_before_cursor,
            include='many_punctuations')
    identifier = None
    try:
        if word_before_cursor:
            if word_before_cursor.endswith(
                    '(') or word_before_cursor.startswith('\\'):
                parsed = sqlparse.parse(text_before_cursor)
            else:
                parsed = sqlparse.parse(
                    text_before_cursor[:-len(word_before_cursor)])
                p = sqlparse.parse(word_before_cursor)[0]
                if p.tokens and isinstance(p.tokens[0], Identifier):
                    identifier = p.tokens[0]
        else:
            parsed = sqlparse.parse(text_before_cursor)
    except (TypeError, AttributeError):
        return [{'type': 'keyword'}]
    if len(parsed) > 1:
        current_pos = len(text_before_cursor)
        stmt_start, stmt_end = 0, 0
        for statement in parsed:
            stmt_len = len(str(statement))
            stmt_start, stmt_end = stmt_end, stmt_end + stmt_len
            if stmt_end >= current_pos:
                text_before_cursor = full_text[stmt_start:current_pos]
                full_text = full_text[stmt_start:]
                break
    elif parsed:
        statement = parsed[0]
    else:
        statement = None
    if statement:
        tok1 = statement.token_first()
        if tok1 and (tok1.value == 'source' or tok1.value.startswith('\\')):
            return suggest_special(text_before_cursor)
    last_token = statement and statement.token_prev(len(statement.tokens))[1] or ''
    return suggest_based_on_last_token(last_token, text_before_cursor,
                                       full_text, identifier)
suggest_type(full_text='SELECT  FROM tabl', text_before_cursor='SELECT ')

'SELECT  FROM tabl'

'SELECT  FROM tabl'

(<Statement 'SELECT ' at 0x7F95D0DD9D60>,)


def extract_from_part(parsed, stop_at_punctuation=True):
    tbl_prefix_seen = False
    for item in parsed.tokens:
        if tbl_prefix_seen:
            if is_subselect(item):
                for x in extract_from_part(item, stop_at_punctuation):
                    yield x
            elif stop_at_punctuation and item.ttype is Punctuation:
                return
            elif item.ttype is Keyword and item.value.upper() == 'ON':
                tbl_prefix_seen = False
                continue
            elif item.ttype is Keyword and (
                    not item.value.upper() == 'FROM') and (
                    not item.value.upper().endswith('JOIN')):
                return
            else:
                yield item
        elif ((item.ttype is Keyword or item.ttype is Keyword.DML) and
                item.value.upper() in ('COPY', 'FROM', 'INTO', 'UPDATE', 'TABLE', 'JOIN',)):
            tbl_prefix_seen = True
        elif isinstance(item, IdentifierList):
            for identifier in item.get_identifiers():
                if (identifier.ttype is Keyword and
                        identifier.value.upper() == 'FROM'):
                    tbl_prefix_seen = True
                    break
extract_from_part(parsed=<Statement 'SELECT ' at 0x7F95D0A07120>, stop_at_punctuation=False)


def parse_special_command(sql):
    command, _, arg = sql.partition(' ')
    verbose = '+' in command
    command = command.strip().replace('+', '')
    return (command, verbose, arg.strip())
parse_special_command(sql='\\. ')


def get_mylogin_cnf_path():
    mylogin_cnf_path = os.getenv('MYSQL_TEST_LOGIN_FILE')
    if mylogin_cnf_path is None:
        app_data = os.getenv('APPDATA')
        default_dir = os.path.join(app_data, 'MySQL') if app_data else '~'
        mylogin_cnf_path = os.path.join(default_dir, '.mylogin.cnf')
    mylogin_cnf_path = os.path.expanduser(mylogin_cnf_path)
    if exists(mylogin_cnf_path):
        logger.debug("Found login path file at '{0}'".format(mylogin_cnf_path))
        return mylogin_cnf_path
    return None
get_mylogin_cnf_path()


default_dir = os.path.join(app_data, 'MySQL') if app_data else '~'


def read_config_files(files, list_values=True):
    config = create_default_config(list_values=list_values)
    _files = copy(files)
    while _files:
        _file = _files.pop(0)
        _config = read_config_file(_file, list_values=list_values)
        if config is not None:
            _files = get_included_configs(_file) + _files
        if bool(_config) is True:
            config.merge(_config)
            config.filename = _config.filename
    return config
read_config_files(files=['/etc/myclirc', '/home/XXX/.config/mycli/myclirc', '~/.myclirc', '/local/rcs/XXX/code/pytrace-collector/logs/self_collected/tried/dbcli+mycli/dbcli+mycli/.myclirc'], list_values=True)

ConfigObj({'main': {'smart_completion': 'True', 'multi_line': 'False', 'destructive_warning': 'True', 'log_file': '~/.mycli.log', 'log_level': 'INFO', 'timing': 'True', 'beep_after_seconds': '0', 'table_format': 'ascii', 'syntax_style': 'default', 'key_bindings': 'emacs', 'wider_completion_menu': 'False', 'prompt': '\\t \\u@\\h:\\d> ', 'prompt_continuation': '->', 'less_chatty': 'False', 'login_path_as_host': 'False', 'auto_vertical_output': 'False', 'keyword_casing': 'auto', 'enable_pager': 'True', 'pager': 'less'}, 'colors': {'completion-menu.completion.current': 'bg:#ffffff #000000', 'completion-menu.completion': 'bg:#008888 #ffffff', 'completion-menu.meta.completion.current': 'bg:#44aaaa #000000', 'completion-menu.meta.completion': 'bg:#448888 #ffffff', 'completion-menu.multi-column-meta': 'bg:#aaffff #000000', 'scrollbar.arrow': 'bg:#003333', 'scrollbar': 'bg:#00aaaa', 'selected': '#ffffff bg:#6666aa', 'search': '#ffffff bg:#4444aa', 'search.current': '#ffffff bg:#44aa44', 'bottom-toolbar': 'bg:#222222 #aaaaaa', 'bottom-toolbar.off': 'bg:#222222 #888888', 'bottom-toolbar.on': 'bg:#222222 #ffffff', 'search-toolbar': 'noinherit bold', 'search-toolbar.text': 'nobold', 'system-toolbar': 'noinherit bold', 'arg-toolbar': 'noinherit bold', 'arg-toolbar.text': 'nobold', 'bottom-toolbar.transaction.valid': 'bg:#222222 #00ff5f bold', 'bottom-toolbar.transaction.failed': 'bg:#222222 #ff005f bold', 'output.header': '#00ff5f bold', 'output.odd-row': '', 'output.even-row': '', 'output.null': '#808080'}, 'favorite_queries': {}, 'alias_dsn': {}})