I have the following code. D_CONFIG_PATH
IS ~/winnie/poohbear.toml
def get_config_path():
default_path = os.path.expanduser(const.D_CONFIG_PATH)
final_path = os.getenv('CONFIG_PATH', default_path)
if not final_path.is_file():
raise FileNotFoundError(f'File {final_path} does not exist')
return final_path
Whenever this uses CONFIG_PATH
, I'd like it to use Pathlib's Path().resolve()
.
Is the best way going to be to do something like
if final_path not '~/winnie/poohbear.toml' then Path(final_path).resolve()
Is there a way to use pathlib all together to be able to do either ~/ when it is that and then a direct path like /home/roland when it is like that?