3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
24 This module is a replacement for the stock tempfile module in Python,
25 and provides only in-memory temporary files as implemented by
26 cStringIO. The only functionality provided is the TemporaryFile
31 from cStringIO
import StringIO
33 from StringIO
import StringIO
38 "NamedTemporaryFile", "mkstemp", "mkdtemp", "mktemp",
39 "TMP_MAX", "gettempprefix", "tempdir", "gettempdir",
48 def TemporaryFile(mode
='w+b', bufsize
=-1, suffix
="",
49 prefix
=template
, dir=None):
50 """Create and return a temporary file.
52 'prefix', 'suffix', 'dir', 'mode', 'bufsize' are all ignored.
54 Returns an object with a file-like interface. The file is in memory
55 only, and does not exist on disk.
60 def PlaceHolder(*args
, **kwargs
):
61 raise NotImplementedError("Only tempfile.TemporaryFile is available for use")
63 NamedTemporaryFile
= PlaceHolder
67 gettempprefix
= PlaceHolder
69 gettempdir
= PlaceHolder