qcodes/tests/common.py
def default_config(user_config: Optional[str] = None):
    """
    Context manager to temporarily establish default config settings.
    This is achieved by overwriting the config paths of the user-,
    environment-, and current directory-config files with the path of the
    config file in the qcodes repository.
    Additionally the current config object `qcodes.config` gets copied and
    reestablished.

    Args:
        user_config: represents the user config file content.
    """
    home_file_name = Config.home_file_name
    schema_home_file_name = Config.schema_home_file_name
    env_file_name = Config.env_file_name
    schema_env_file_name = Config.schema_env_file_name
    cwd_file_name = Config.cwd_file_name
    schema_cwd_file_name = Config.schema_cwd_file_name

    Config.home_file_name = ''
    with tempfile.TemporaryDirectory() as tmpdirname:
        file_name = os.path.join(tmpdirname, 'user_config.json')
        file_name_schema = os.path.join(tmpdirname, 'user_config_schema.json')
        if user_config is not None:
            with open(file_name, 'w') as f:
                f.write(user_config)

        Config.home_file_name = file_name
        Config.schema_home_file_name = file_name_schema
        Config.env_file_name = ''
        Config.schema_env_file_name = ''
        Config.cwd_file_name = ''
        Config.schema_cwd_file_name = ''

        default_config_obj: Optional[DotDict] = copy.\
            deepcopy(qcodes.config.current_config)
        qcodes.config = Config()

        try:
            yield
        finally:
            Config.home_file_name = home_file_name
            Config.schema_home_file_name = schema_home_file_name
            Config.env_file_name = env_file_name
            Config.schema_env_file_name = schema_env_file_name
            Config.cwd_file_name = cwd_file_name
            Config.schema_cwd_file_name = schema_cwd_file_name

            qcodes.config.current_config = default_config_obj

    Context manager to temporarily establish default config settings.
    This is achieved by overwriting the config paths of the user-,
    environment-, and current directory-config files with the path of the
    config file in the qcodes repository.
    Additionally the current config object `qcodes.config` gets copied and
    reestablished.

    Args:
        user_config: represents the user config file content.
    
Context manager to temporarily establish default config settings.
This is achieved by overwriting the config paths of the user-,
environment-, and current directory-config files with the path of the
config file in the qcodes repository.
Additionally the current config object `qcodes.config` gets copied and
reestablished.
Context manager to temporarily establish default config settings . This is achieved by overwriting the config paths of the user - environment - and current directory - config files with the path of the config file in the qcodes repository . Additionally the current config object ` qcodes . config ` gets copied and reestablished .
def default_config(user_config: Optional[str] = None):
    home_file_name = Config.home_file_name
    schema_home_file_name = Config.schema_home_file_name
    env_file_name = Config.env_file_name
    schema_env_file_name = Config.schema_env_file_name
    cwd_file_name = Config.cwd_file_name
    schema_cwd_file_name = Config.schema_cwd_file_name
    Config.home_file_name = ''
    with tempfile.TemporaryDirectory() as tmpdirname:
        file_name = os.path.join(tmpdirname, 'user_config.json')
        file_name_schema = os.path.join(tmpdirname, 'user_config_schema.json')
        if user_config is not None:
            with open(file_name, 'w') as f:
                f.write(user_config)
        Config.home_file_name = file_name
        Config.schema_home_file_name = file_name_schema
        Config.env_file_name = ''
        Config.schema_env_file_name = ''
        Config.cwd_file_name = ''
        Config.schema_cwd_file_name = ''
        default_config_obj: Optional[DotDict] = copy.\
            deepcopy(qcodes.config.current_config)
        qcodes.config = Config()
        try:
            yield
        finally:
            Config.home_file_name = home_file_name
            Config.schema_home_file_name = schema_home_file_name
            Config.env_file_name = env_file_name
            Config.schema_env_file_name = schema_env_file_name
            Config.cwd_file_name = cwd_file_name
            Config.schema_cwd_file_name = schema_cwd_file_name
            qcodes.config.current_config = default_config_obj
def default_config ( user_config : Optional [ str ] = None ) : home_file_name = Config . home_file_name schema_home_file_name = Config . schema_home_file_name env_file_name = Config . env_file_name schema_env_file_name = Config . schema_env_file_name cwd_file_name = Config . cwd_file_name schema_cwd_file_name = Config . schema_cwd_file_name Config . home_file_name = '' with tempfile . TemporaryDirectory ( ) as tmpdirname : file_name = os . path . join ( tmpdirname , 'user_config.json' ) file_name_schema = os . path . join ( tmpdirname , 'user_config_schema.json' ) if user_config is not None : with open ( file_name , 'w' ) as f : f . write ( user_config ) Config . home_file_name = file_name Config . schema_home_file_name = file_name_schema Config . env_file_name = '' Config . schema_env_file_name = '' Config . cwd_file_name = '' Config . schema_cwd_file_name = '' default_config_obj : Optional [ DotDict ] = copy . deepcopy ( qcodes . config . current_config ) qcodes . config = Config ( ) try : yield finally : Config . home_file_name = home_file_name Config . schema_home_file_name = schema_home_file_name Config . env_file_name = env_file_name Config . schema_env_file_name = schema_env_file_name Config . cwd_file_name = cwd_file_name Config . schema_cwd_file_name = schema_cwd_file_name qcodes . config . current_config = default_config_obj
Context manager to temporarily establish default config settings.
Context manager to temporarily establish default config settings .
"""
    Context manager to temporarily establish default config settings.
    This is achieved by overwriting the config paths of the user-,
    environment-, and current directory-config files with the path of the
    config file in the qcodes repository.
    Additionally the current config object `qcodes.config` gets copied and
    reestablished.

    Args:
        user_config: represents the user config file content.
    """
user_config
Optional[str]
represents the user config file content.
represents the user config file content .