file_path

This commit is contained in:
JJJHolscher 2023-09-28 15:11:07 +02:00
parent 1609b3da89
commit 8d948fd2ca

View File

@ -7,8 +7,8 @@ import __main__
def root_dir(): def root_dir():
if "FILE_NAME" in os.environ: if "FILE_PATH" in os.environ:
return Path(os.environ["FILE_NAME"]).parent() return Path(os.environ["FILE_PATH"]).parent()
if __main__.__package__: if __main__.__package__:
return files(__main__.__package__) return files(__main__.__package__)
@ -30,8 +30,11 @@ def root_dir():
def root_file(): def root_file():
if "FILE_PATH" in os.environ:
return Path(os.environ["FILE_PATH"])
if "FILE_NAME" in os.environ: if "FILE_NAME" in os.environ:
return Path(os.environ["FILE_NAME"]) return root_dir() / os.environ["FILE_NAME"]
if "__file__" in dir(__main__): if "__file__" in dir(__main__):
return Path(__main__.__file__) return Path(__main__.__file__)