Allow custom temp file suffixes

This commit is contained in:
2Shirt 2020-01-23 18:56:11 -07:00
parent 1b643f3918
commit 25c532881e
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -56,9 +56,12 @@ def get_user_name():
return user
def make_temp_file():
def make_temp_file(suffix=None):
"""Make temporary file, returns pathlib.Path() obj."""
proc = run_program(['mktemp'], check=False)
cmd = ['mktemp']
if suffix:
cmd.append(f'--suffix={suffix}')
proc = run_program(cmd)
return pathlib.Path(proc.stdout.strip())