in dynalab_cli/init.py [0:0]
def create_file(self, key):
filename = default_filename(key)
filepath = os.path.join(self.root_dir, filename)
printpath = os.path.join(self.work_dir, filename)
if os.path.exists(filepath):
ops = input(f"{printpath} exists. Overwrite? [Y/n] ")
if ops.strip().lower() not in ("y", "yes"):
return None
if key == "handler":
template = os.path.join(
os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
"dynalab",
"handler",
"handler.py.template",
)
with open(template) as f:
content = f.read()
handler_content = content.format(your_task=self.config["task"])
with open(filepath, "w") as f:
f.write(handler_content)
else:
open(filepath, "w+").close()
print(f"Created new {key} file at {printpath}")
return printpath