scyther/gui/Gui/Tempfile.py

42 lines
845 B
Python
Raw Normal View History

2006-08-02 13:59:57 +01:00
#!/usr/bin/python
#---------------------------------------------------------------------------
""" Import externals """
import os
import tempfile
import atexit
#---------------------------------------------------------------------------
""" Local thing (can be done in numerous nicer ways) """
tempfiles = []
#---------------------------------------------------------------------------
def tempremove(tuple):
(fd,fpname) = tuple
#os.close(fd)
os.remove(fpname)
def cleanupshop():
global tempfiles
for tuple in tempfiles:
tempremove(tuple)
def tempcleaned(post=""):
global tempfiles
tuple = tempfile.mkstemp(post,"scyther_")
tempfiles.append(tuple)
return tuple
def tempcleanearly(tuple):
global tempfiles
tempfiles.remove(tuple)
tempremove(tuple)
atexit.register(cleanupshop)