summaryrefslogtreecommitdiff
path: root/fs/tempfs.py
diff options
context:
space:
mode:
authorwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2010-01-01 20:18:32 +0000
committerwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2010-01-01 20:18:32 +0000
commit72f3d49fa73d0b4e5865e8d8d10b8aabc006148e (patch)
treee371fce423086808958d373d869b3fc66ef3e431 /fs/tempfs.py
parentc093c2c8e33c7e00db54507fe03a212967a68eb5 (diff)
downloadpyfilesystem-git-72f3d49fa73d0b4e5865e8d8d10b8aabc006148e.tar.gz
Documentation, fixes, A ReadOnlyFS wrapper and a plain old FTP FS class
Diffstat (limited to 'fs/tempfs.py')
-rw-r--r--fs/tempfs.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/tempfs.py b/fs/tempfs.py
index fc3e7c4..5c35043 100644
--- a/fs/tempfs.py
+++ b/fs/tempfs.py
@@ -1,4 +1,10 @@
-#!/usr/bin/env python
+"""
+fs.tempfs
+=========
+
+Make a temporary file system that exists in a folder provided by the OS. All files contained in a TempFS are removed when the `close` method is called (or when the TempFS is cleaned up by Python).
+
+"""
import os
import time
@@ -6,13 +12,14 @@ import tempfile
from fs.osfs import OSFS
from fs.errors import *
+from fs import _thread_syncronize_default
class TempFS(OSFS):
"""Create a Filesystem in a tempory directory (with tempfile.mkdtemp),
and removes it when the TempFS object is cleaned up."""
- def __init__(self, identifier=None, temp_dir=None, dir_mode=0700, thread_synchronize=True):
+ def __init__(self, identifier=None, temp_dir=None, dir_mode=0700, thread_synchronize=_thread_syncronize_default):
"""Creates a temporary Filesystem
identifier -- A string that is included in the name of the temporary directory,
@@ -29,13 +36,14 @@ class TempFS(OSFS):
__repr__ = __str__
def __unicode__(self):
- return unicode(self.__str__())
+ return u'<TempFS: %s>' % self._temp_dir
def close(self):
"""Removes the temporary directory.
This will be called automatically when the object is cleaned up by
- Python. Note that once this method has been called, the FS object may
+ Python, although it is advisable to call it manually.
+ Note that once this method has been called, the FS object may
no longer be used.
"""
# Depending on how resources are freed by the OS, there could