Files
PyPost/lua/luarails.py

15 lines
436 B
Python

import os
def get_file_contents(filename : str) -> str | None:
""" Gets the Contents of a File and returns it in str format """
script_dir = os.path.dirname(os.path.abspath(__file__))
path = os.path.join(script_dir, filename)
if not os.path.isfile(path):
print(f"File '{filename}' not found in {script_dir}")
return None
with open(path, 'r', encoding='utf-8') as file:
return file.read()