






import textwrap

import pyarrow as pa
import pytest

from datasets import Features, Value
from datasets.packaged_modules.json.json import Json
@pytest.fixture
def 							UpperCAmelCase   ( _lowercase   ):


    '''simple docstring'''



    _lowercase     			=						tmp_path / 'file.jsonl'
    _lowercase     			=						textwrap.dedent(
        '\\n        {"col_1": -1}\n        {"col_1": 1, "col_2": 2}\n        {"col_1": 10, "col_2": 20}\n        '   )
    with open(_lowercase,   'w'   ) as f:
        f.write(_lowercase   )
    return str(_lowercase   )
@pytest.fixture
def 							UpperCAmelCase   ( _lowercase   ):


    '''simple docstring'''



    _lowercase     			=						tmp_path / 'file_utf16_encoded.jsonl'
    _lowercase     			=						textwrap.dedent(
        '\\n        {"col_1": -1}\n        {"col_1": 1, "col_2": 2}\n        {"col_1": 10, "col_2": 20}\n        '   )
    with open(_lowercase,   'w',   encoding='utf-16'   ) as f:
        f.write(_lowercase   )
    return str(_lowercase   )
@pytest.fixture
def 							UpperCAmelCase   ( _lowercase   ):


    '''simple docstring'''



    _lowercase     			=						tmp_path / 'file_with_list_of_dicts.json'
    _lowercase     			=						textwrap.dedent(
        '\\n        [\n            {"col_1": -1},\n            {"col_1": 1, "col_2": 2},\n            {"col_1": 10, "col_2": 20}\n        ]\n        '   )
    with open(_lowercase,   'w'   ) as f:
        f.write(_lowercase   )
    return str(_lowercase   )
@pytest.fixture
def 							UpperCAmelCase   ( _lowercase   ):


    '''simple docstring'''



    _lowercase     			=						tmp_path / 'file_with_list_of_dicts_field.json'
    _lowercase     			=						textwrap.dedent(
        '\\n        {\n            "field1": 1,\n            "field2": "aabb",\n            "field3": [\n                {"col_1": -1},\n                {"col_1": 1, "col_2": 2},\n                {"col_1": 10, "col_2": 20}\n            ]\n        }\n        '   )
    with open(_lowercase,   'w'   ) as f:
        f.write(_lowercase   )
    return str(_lowercase   )
@pytest.mark.parametrize(
    'file_fixture, config_kwargs',   [
        ('jsonl_file', {}),
        ('jsonl_file_utf16_encoded', {'encoding': 'utf-16'}),
        ('json_file_with_list_of_dicts', {}),
        ('json_file_with_list_of_dicts_field', {'field': 'field3'}),
    ],   )
def 							UpperCAmelCase   ( _lowercase,   _lowercase,   _lowercase   ):


    '''simple docstring'''



    _lowercase     			=						Json(**_lowercase   )
    _lowercase     			=						json._generate_tables([[request.getfixturevalue(_lowercase   )]]   )
    _lowercase     			=						pa.concat_tables([table for _, table in generator]   )
    assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20]}
@pytest.mark.parametrize(
    'file_fixture, config_kwargs',   [
        (
            'jsonl_file',
            {'features': Features({'col_1': Value('int64'   ), 'col_2': Value('int64'   ), 'missing_col': Value('string'   )}   )},
        ),
        (
            'json_file_with_list_of_dicts',
            {'features': Features({'col_1': Value('int64'   ), 'col_2': Value('int64'   ), 'missing_col': Value('string'   )}   )},
        ),
        (
            'json_file_with_list_of_dicts_field',
            {
                'field': 'field3',
                'features': Features(
                    {'col_1': Value('int64'   ), 'col_2': Value('int64'   ), 'missing_col': Value('string'   )}   ),
            },
        ),
    ],   )
def 							UpperCAmelCase   ( _lowercase,   _lowercase,   _lowercase   ):


    '''simple docstring'''



    _lowercase     			=						Json(**_lowercase   )
    _lowercase     			=						json._generate_tables([[request.getfixturevalue(_lowercase   )]]   )
    _lowercase     			=						pa.concat_tables([table for _, table in generator]   )
    assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20], "missing_col": [None, None, None]}








from typing import Literal

lowerCamelCase					    =	'''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''
def 							UpperCAmelCase   ( _lowercase,   _lowercase,   _lowercase   ):


    '''simple docstring'''



    _lowercase     			=						LETTERS if mode == 'decrypt' else key
    _lowercase     			=						key if mode == 'decrypt' else LETTERS
    _lowercase     			=						''
    # loop through each symbol in the message
    for symbol in message:
        if symbol.upper() in chars_a:
            # encrypt/decrypt the symbol
            _lowercase     			=						chars_a.find(symbol.upper()   )
            if symbol.isupper():
                translated += chars_b[sym_index].upper()
            else:
                translated += chars_b[sym_index].lower()
        else:
            # symbol is not in LETTERS, just add it
            translated += symbol
    return translated
def 							UpperCAmelCase   ( _lowercase,   _lowercase   ):


    '''simple docstring'''



    return translate_message(_lowercase,   _lowercase,   'encrypt'   )
def 							UpperCAmelCase   ( _lowercase,   _lowercase   ):


    '''simple docstring'''



    return translate_message(_lowercase,   _lowercase,   'decrypt'   )
def 							UpperCAmelCase   ( ):


    '''simple docstring'''



    _lowercase     			=						'Hello World'
    _lowercase     			=						'QWERTYUIOPASDFGHJKLZXCVBNM'
    _lowercase     			=						'decrypt'  # set to 'encrypt' or 'decrypt'

    if mode == "encrypt":
        _lowercase     			=						encrypt_message(_lowercase,   _lowercase   )
    elif mode == "decrypt":
        _lowercase     			=						decrypt_message(_lowercase,   _lowercase   )
    print(f'''Using the key {key}, the {mode}ed message is: {translated}'''   )


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   main()
