/usr/local/lib/python3.6/site-packages/datasets/utils/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/datasets/utils/__pycache__/patching.cpython-36.pyc (3438B)
3
<%Eg] @ s@ d dl mZ ddlmZ eeZG dd dZG dd dZdS ) )
import_module )
get_loggerc @ s e Zd ZdZdddZdS )_PatchedModuleObjzMSet all the modules components as attributes of the _PatchedModuleObj object.Nc C s` |pg }|d k rFx4|j D ]*}||ks0|jd rt| |t|| qW t|trV|jn|| _d S )N__)__dict__
startswithsetattrgetattr
isinstancer _original_module)selfmoduleattrskey r A/usr/local/lib/python3.6/site-packages/datasets/utils/patching.py__init__ s z_PatchedModuleObj.__init__)N)__name__
__module____qualname____doc__r r r r r r s r c @ sD e Zd ZdZg ZdedddZdd Zdd Zd
d Z dd
Z
dS )patch_submoduleaF
Patch a submodule attribute of an object, by keeping all other submodules intact at all levels.
Example::
>>> import importlib
>>> from datasets.load import dataset_module_factory
>>> from datasets.streaming import patch_submodule, xjoin
>>>
>>> dataset_module = dataset_module_factory("snli")
>>> snli_module = importlib.import_module(dataset_module.module_path)
>>> patcher = patch_submodule(snli_module, "os.path.join", xjoin)
>>> patcher.start()
>>> assert snli_module.os.path.join is xjoin
N)targetc C s6 || _ || _|| _|jdd | _i | _|p.g | _d S )N.r )objr newsplitr originalr )r
r r r r r r r r ( s zpatch_submodule.__init__c
C s | j jd^ }}xtt|D ]}ytdj|d |d }W n tk
rZ w"Y nX x| jj D ]}t | j|}||kst
|to|j|krh|| j
|<