importos# files added to stdlib in 3.9fromimportlib.resourcesimportfilesfrompathlibimportPathQCODES_USER_PATH_ENV="QCODES_USER_PATH"
[docs]defget_qcodes_path(*subfolder:str)->str:""" Return full file path of the QCoDeS module. Additional arguments will be appended as subfolder. """returnstr(files("qcodes").joinpath(*subfolder))+os.sep
[docs]defget_qcodes_user_path(*file_parts:str)->str:""" Get ``~/.qcodes`` path or if defined the path defined in the ``QCODES_USER_PATH`` environment variable. Returns: path to the user qcodes directory """path=os.environ.get(QCODES_USER_PATH_ENV,os.path.join(Path.home(),".qcodes"))os.makedirs(os.path.dirname(path),exist_ok=True)returnos.path.join(path,*file_parts)