Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created Temporary file/directory support #1540 #1585

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions openage/codegen/Temporary file/directory support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import tempfile
import shutil
import os

class FileSystemAPI:
def __init__(self):
pass

def create_temp_file(self):
temp_file = tempfile.NamedTemporaryFile(delete=False)
return temp_file.name

def create_temp_dir(self):
temp_dir = tempfile.mkdtemp()
return temp_dir

def delete_temp(self, path):
if os.path.isfile(path):
os.remove(path)
elif os.path.isdir(path):
shutil.rmtree(path)

def use_temp_in_converter(self):
temp_file_path = self.create_temp_file()
print(f"Temporary file path created: {temp_file_path}")



fs = FileSystemAPI()
fs.use_temp_in_converter()