

import re
import tempfile
import unittest
from pathlib import Path

from datasets.utils.metadata import DatasetMetadata
def 		_snake_case(       SCREAMING_SNAKE_CASE__     :      str )				-> str:





    '''simple docstring'''






    A__        =  min(re.search('^ +'       ,     SCREAMING_SNAKE_CASE__ ).end() if t.startswith(' ' ) else 0 for t in string.splitlines() )
    return "\n".join([line[indent_level:] for line in string.splitlines() if indent_level < len(SCREAMING_SNAKE_CASE__ )] )


lowercase_									=    "\\n---\nlanguage:\n- zh\n- en\ntask_ids:\n- sentiment-classification\n---\n# Begin of markdown\n\nSome cool dataset card\n"

lowercase_									=    "\\n---\n---\n# Begin of markdown\n\nSome cool dataset card\n"


lowercase_									=    "\\n# Begin of markdown\n\nSome cool dataset card\n"


class 					A		(				unittest.TestCase					):







    """simple docstring"""





    def 		snake_case__	( self					:			List[Any]						)->       str:





        '''simple docstring'''







        with tempfile.TemporaryDirectory() as tmp_dir:
            A__        =  Path(lowercase_						) / 'README.md'
            with open(lowercase_,'w+'						) as readme_file:
                readme_file.write(lowercase_						)
            A__        =  DatasetMetadata.from_readme(lowercase_						)
            self.assertDictEqual(lowercase_,{'language': ['zh', 'en'], 'task_ids': ['sentiment-classification']}						)

            with open(lowercase_,'w+'						) as readme_file:
                readme_file.write(lowercase_						)
            A__        =  DatasetMetadata.from_readme(lowercase_						)
            self.assertDictEqual(lowercase_,{}						)

            with open(lowercase_,'w+'						) as readme_file:
                readme_file.write(lowercase_						)
            A__        =  DatasetMetadata.from_readme(lowercase_						)
            self.assertEqual(lowercase_,{}						)


    def 		snake_case__	( self					:			Tuple						)->       List[Any]:





        '''simple docstring'''







        A__        =  _dedent(
            '\\n            annotations_creators:\n            - found\n            language_creators:\n            - found\n            language:\n            - en\n            license:\n            - unknown\n            multilinguality:\n            - monolingual\n            pretty_name: Test Dataset\n            size_categories:\n            - 10K<n<100K\n            source_datasets:\n            - extended|other-yahoo-webscope-l6\n            task_categories:\n            - question-answering\n            task_ids:\n            - open-domain-qa\n            '						)
        assert DatasetMetadata.from_yaml_string(lowercase_						)

        A__        =  _dedent(
            '\\n            annotations_creators:\n            - found\n            language:\n            - en\n            license:\n            - unknown\n            multilinguality:\n            - monolingual\n            pretty_name: Test Dataset\n            size_categories:\n            - 10K<n<100K\n            source_datasets:\n            - extended|other-yahoo-webscope-l6\n            task_categories:\n            - question-answering\n            task_ids:\n            - open-domain-qa\n            task_ids:\n            - open-domain-qa\n            '						)
        with self.assertRaises(lowercase_						):
            DatasetMetadata.from_yaml_string(lowercase_						)

        A__        =  _dedent(
            '\\n            annotations_creators:\n            - found\n            language_creators:\n            - found\n            language:\n            - en\n            license:\n            - unknown\n            multilinguality:\n            - monolingual\n            pretty_name: Test Dataset\n            size_categories:\n            - 10K<n<100K\n            source_datasets:\n            - extended|other-yahoo-webscope-l6\n            task_categories:\n            - text-classification\n            task_ids:\n            - multi-class-classification\n            paperswithcode_id:\n            - squad\n            configs:\n            - en\n            train-eval-index:\n            - config: en\n              task: text-classification\n              task_id: multi_class_classification\n              splits:\n                train_split: train\n                eval_split: test\n              col_mapping:\n                text: text\n                label: target\n              metrics:\n                - type: accuracy\n                  name: Accuracy\n            extra_gated_prompt: |\n              By clicking on “Access repository” below, you also agree to ImageNet Terms of Access:\n              [RESEARCHER_FULLNAME] (the "Researcher") has requested permission to use the ImageNet database (the "Database") at Princeton University and Stanford University. In exchange for such permission, Researcher hereby agrees to the following terms and conditions:\n              1. Researcher shall use the Database only for non-commercial research and educational purposes.\n            extra_gated_fields:\n              Company: text\n              Country: text\n              I agree to use this model for non-commerical use ONLY: checkbox\n            '						)
        assert DatasetMetadata.from_yaml_string(lowercase_						)




import enum
import inspect
import warnings
from functools import wraps
from typing import Callable, Optional

from .logging import get_logger


lowercase_									=    set()
lowercase_									=    get_logger(__name__)
def 		_snake_case(       SCREAMING_SNAKE_CASE__     :      Optional[str] = None )				-> Optional[int]:





    '''simple docstring'''






    def decorator(SCREAMING_SNAKE_CASE__     :      Callable ):
        global _emitted_deprecation_warnings

        if inspect.isclass(SCREAMING_SNAKE_CASE__ ):
            A__        =  deprecated_class_or_function.__init__
            A__        =  deprecated_class_or_function.__name__
        else:
            A__        =  deprecated_class_or_function
            A__        =  deprecated_function.__name__
            # Support deprecating __init__ class method: class name instead
            A__        =  name if name != '__init__' else deprecated_function.__qualname__.split('.' )[-2]

        A__        =  (
            f'{name} is deprecated and will be removed in the next major version of datasets.' + f' {help_message}'
            if help_message
            else ''
        )

        @wraps(SCREAMING_SNAKE_CASE__ )
        def wrapper(*SCREAMING_SNAKE_CASE__     :      Tuple       ,     **SCREAMING_SNAKE_CASE__     :      Any ):
            A__        =  hash(SCREAMING_SNAKE_CASE__ )
            if func_hash not in _emitted_deprecation_warnings:
                warnings.warn(SCREAMING_SNAKE_CASE__       ,     category=SCREAMING_SNAKE_CASE__       ,     stacklevel=2 )
                _emitted_deprecation_warnings.add(SCREAMING_SNAKE_CASE__ )
            return deprecated_function(*SCREAMING_SNAKE_CASE__       ,     **SCREAMING_SNAKE_CASE__ )

        A__        =  'deprecated'

        if inspect.isclass(SCREAMING_SNAKE_CASE__ ):
            A__        =  wrapper
            return deprecated_class_or_function
        else:
            return wrapper

    return decorator


class 					A		(				enum.EnumMeta					):







    """simple docstring"""





    def __getattribute__( cls					:			Optional[Any],lowercase_					:			int						)->       Optional[Any]:





        '''simple docstring'''







        A__        =  super().__getattribute__(lowercase_						)
        if isinstance(lowercase_,enum.Enum						) and obj._on_access:
            obj._on_access()
        return obj


    def __getitem__( cls					:			int,lowercase_					:			Any						)->       Tuple:





        '''simple docstring'''







        A__        =  super().__getitem__(lowercase_						)
        if member._on_access:
            member._on_access()
        return member


    def __call__( cls					:			Optional[int],lowercase_					:			Tuple,lowercase_					:			List[Any]=None,*, lowercase_					:			Any=None,lowercase_					:			Optional[Any]=None,lowercase_					:			Any=None,lowercase_					:			Optional[int]=1						)->       List[str]:





        '''simple docstring'''







        A__        =  super().__call__(lowercase_,lowercase_,module=lowercase_,qualname=lowercase_,type=lowercase_,start=lowercase_						)
        if isinstance(lowercase_,enum.Enum						) and obj._on_access:
            obj._on_access()
        return obj




class 					A		(				enum.Enum       ,				metaclass=_UpperCAmelCase					):







    """simple docstring"""





    def __new__( cls					:			Any,lowercase_					:			str						)->       Any:





        '''simple docstring'''







        A__        =  object.__new__(cls						)
        A__        =  value
        A__        =  member.deprecate
        return member


    @property
    def 		snake_case__	( self					:			List[Any]						)->       List[Any]:





        '''simple docstring'''







        return ""


    def 		snake_case__	( self					:			List[str]						)->       Dict:





        '''simple docstring'''







        A__        =  F' {self.help_message}' if self.help_message else ''
        warnings.warn(
            F'\'{self.__objclass__.__name__}\' is deprecated and will be removed in the next major version of datasets.'
            + help_message,lowercase_,stacklevel=3,)

