reportlab.lib: break out rltempfile.py to avoid rl_accel imports
authorrgbecker
Fri, 19 May 2006 14:16:02 +0000
changeset 2625 71abbda1f58c
parent 2624 565a8e1f9df7
child 2626 4376a2bdc5c8
reportlab.lib: break out rltempfile.py to avoid rl_accel imports
reportlab/lib/rltempfile.py
reportlab/lib/utils.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reportlab/lib/rltempfile.py	Fri May 19 14:16:02 2006 +0000
@@ -0,0 +1,29 @@
+#Copyright ReportLab Europe Ltd. 2000-2006
+#see license.txt for license details
+# $URI:$
+__version__=''' $Id$ '''
+_rl_tempdir=None
+__all__ = ('get_rl_tempdir', 'get_rl_tempdir')
+import os, tempfile
+def _rl_getuid():
+    if hasattr(os,'getuid'):
+        return os.getuid()
+    else:
+        return ''
+
+def get_rl_tempdir(*subdirs):
+    global _rl_tempdir
+    if _rl_tempdir is None:
+        _rl_tempdir = os.path.join(tempfile.gettempdir(),'ReportLab_tmp%s' % str(_rl_getuid()))
+    d = _rl_tempdir
+    if subdirs: d = os.path.join(*((d,)+subdirs))
+    try:
+        os.makedirs(d)
+    except:
+        pass
+    return d
+
+def get_rl_tempfile(fn=None):
+    if not fn:
+        fn = tempfile.mktemp()
+    return os.path.join(get_rl_tempdir(),fn)
--- a/reportlab/lib/utils.py	Fri May 19 11:34:32 2006 +0000
+++ b/reportlab/lib/utils.py	Fri May 19 14:16:02 2006 +0000
@@ -1,11 +1,12 @@
-#Copyright ReportLab Europe Ltd. 2000-2004
+#Copyright ReportLab Europe Ltd. 2000-2006
 #see license.txt for license details
-#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/lib/utils.py
+# $URI:$
 __version__=''' $Id$ '''
 
 import string, os, sys, imp
 from reportlab.lib.logger import warnOnce
 from types import *
+from rltempfile import get_rl_tempfile, get_rl_tempdir, _rl_getuid
 SeqTypes = (ListType,TupleType)
 if sys.hexversion<0x2020000:
     def isSeqType(v):
@@ -245,32 +246,6 @@
     def fp_str(*a):
         return string.replace(apply(_FP_STR,a),',','.')
 
-def _rl_getuid():
-    if hasattr(os,'getuid'):
-        return os.getuid()
-    else:
-        return ''
-
-_rl_tempdir=None
-def get_rl_tempdir(*subdirs):
-    global _rl_tempdir
-    if _rl_tempdir is None:
-        import tempfile
-        _rl_tempdir = os.path.join(tempfile.gettempdir(),'ReportLab_tmp%s' % str(_rl_getuid()))
-    d = _rl_tempdir
-    if subdirs: d = os.path.join(*((d,)+subdirs))
-    try:
-        os.makedirs(d)
-    except:
-        pass
-    return d
-
-def get_rl_tempfile(fn=None):
-    if not fn:
-        import tempfile
-        fn = tempfile.mktemp()
-    return os.path.join(get_rl_tempdir(),fn)
-
 def recursiveImport(modulename, baseDir=None, noCWD=0, debug=0):
     """Dynamically imports possible packagized module, or raises ImportError"""
     normalize = lambda x: os.path.normcase(os.path.abspath(os.path.normpath(x)))