Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Restore ability to use tempfile kwargs other than dir (#40)
Browse files Browse the repository at this point in the history
The changes in #38 broke the ability to use prefix, suffix and bufsize arguments when creating the tempfile. This commit restores the ability.
  • Loading branch information
GlenWalker authored and untitaker committed Feb 1, 2019
1 parent 217662d commit 1e7cce5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions atomicwrites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ def _open(self, get_fileobject):
except Exception:
pass

def get_fileobject(self, dir=None, **kwargs):
def get_fileobject(self, suffix="", prefix=tempfile.template, dir=None,
**kwargs):
'''Return the temporary file to use.'''
if dir is None:
dir = os.path.normpath(os.path.dirname(self._path))
descriptor, name = tempfile.mkstemp(dir=dir)
descriptor, name = tempfile.mkstemp(suffix=suffix, prefix=prefix,
dir=dir)
# io.open() will take either the descriptor or the name, but we need
# the name later for commit()/replace_atomic() and couldn't find a way
# to get the filename from the descriptor.
Expand Down

0 comments on commit 1e7cce5

Please sign in to comment.