Update of /cvsroot/webware/Webware/MiscUtils
In directory sc8-pr-cvs1:/tmp/cvs-serv4939
Modified Files:
Funcs.py
Log Message:
- added mktemp()
Index: Funcs.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiscUtils/Funcs.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Funcs.py 15 Nov 2002 10:20:58 -0000 1.14
--- Funcs.py 9 Dec 2002 05:32:43 -0000 1.15
***************
*** 54,57 ****
--- 54,77 ----
+ import tempfile
+ def mktemp(suffix="", dir=None):
+ """
+ User-callable function to return a unique temporary file name.
+
+ Duplicated from Python's own tempfile with the optional "dir"
+ argument added. This allows customization of the directory, without
+ having to take over the module level variable, tempdir.
+
+ @@ 2002-12-08 ce: should submit this to Python
+ """
+ if not dir: dir = tempfile.gettempdir()
+ pre = tempfile.gettempprefix()
+ while 1:
+ i = tempfile._counter.get_next()
+ file = os.path.join(dir, pre + str(i) + suffix)
+ if not os.path.exists(file):
+ return file
+
+
def wordWrap(s, width=78):
"""
|