bifroyst/source/helpers/misc.py
2026-04-29 23:46:44 +02:00

51 lines
871 B
Python

import sys as _sys
import os as _os
def convey(value, functions):
result = value
for function in functions:
result = function(result)
return result
def string_coin(template, arguments):
result = template
for (key, value, ) in arguments.items():
result = result.replace("{{%s}}" % key, value)
return result
def file_read(path):
handle = open(path, "r")
content = handle.read()
handle.close()
return content
def file_write(path, content):
handle = open(path, "w")
handle.write(content)
handle.close()
def directory_create(path):
steps = _os.path.split(path)
for index in range(len(steps)):
path_ = _os.path.join(*(steps[:(index+1)]))
if (path_ == ""):
pass
else:
if (_os.path.exists(path_)):
pass
else:
_os.mkdir(path_)
def shell_exec(
command
):
_sys.stderr.write("\n>> %s\n" % command)
_os.system(command)