summaryrefslogtreecommitdiff
path: root/fs/__init__.py
blob: 1c52c87d5aa50aae029d4fbc3aed8d2860749d6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""

  fs:  a filesystem abstraction.

This module provides an abstract base class 'FS' that defines a consistent
interface to different kinds of filesystem, along with a range of concrete
implementations of this interface such as:

    OSFS:       access the local filesystem, through the 'os' module
    TempFS:     a temporary filesystem that's automatically cleared on exit
    MemoryFS:   a filesystem that exists only in memory
    ZipFS:      access a zipfile like a filesystem
    SFTPFS:     access files on a SFTP server
    S3FS:       access files stored in Amazon S3

"""

__version__ = "0.2.0a9"
__author__ = "Will McGugan (will@willmcgugan.com)"

#  'base' imports * from 'path' and 'errors', so their
#  contents will be available here as well.
from base import *

#  provide these by default so people can use 'fs.path.basename' etc.
import errors
import path

_thread_synchronize_default = True
def set_thread_synchronize_default(sync):
    """Sets the default thread synctonisation flag.
    
    FS objects are made thread-safe through the use of a per-FS threading Lock
    object. Since this can introduce an small overhead it can be disabled with
    this function if the code is single-threaded.
    
    :param sync: Set wether to use thread synchronization for new FS objects
    
    """
    global _thread_synchronization_default
    _thread_synchronization_default = sync

# Store some identifiers in the fs namespace
import os
SEEK_CUR = os.SEEK_CUR
SEEK_END = os.SEEK_END
SEEK_SET = os.SEEK_SET