~sschwarzer/ftputil

ftputil/ftputil/__init__.py -rw-r--r-- 1.9 KiB
77f2ca24Stefan Schwarzer Move item "Push to repository" a month ago
                                                                                
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
48
49
50
51
52
53
# Copyright (C) 2002-2018, Stefan Schwarzer <sschwarzer@sschwarzer.net>
# and ftputil contributors (see `doc/contributors.txt`)
# See the file LICENSE for licensing terms.

"""
ftputil - high-level FTP client library

FTPHost objects
    This class resembles the `os` module's interface to ordinary file
    systems. In addition, it provides a method `file` which will
    return file-objects corresponding to remote files.

    # Example session
    with ftputil.FTPHost("ftp.domain.com", "me", "secret") as host:
        print(host.getcwd())  # e. g. "/home/me"
        host.mkdir("newdir")
        host.chdir("newdir")
        with host.open("sourcefile", "r") as source:
            with host.open("targetfile", "w") as target:
                host.copyfileobj(source, target)
        host.remove("targetfile")
        host.chdir(host.pardir)
        host.rmdir("newdir")

    There are also shortcuts for uploads and downloads:

    host.upload(local_file, remote_file)
    host.download(remote_file, local_file)

    Both accept an additional mode parameter. If it is "b", the
    transfer mode will be for binary files.

    For even more functionality refer to the documentation in
    `ftputil.txt` or `ftputil.html`.

FTPFile objects
    `FTPFile` objects are constructed via the `file` method (`open`
    is an alias) of `FTPHost` objects. `FTPFile` objects support the
    usual file operations for non-seekable files (`read`, `readline`,
    `readlines`, `write`, `writelines`, `close`).

Note: ftputil currently is not threadsafe. More specifically, you can
      use different `FTPHost` objects in different threads but not
      a single `FTPHost` object in different threads.
"""

from ftputil.host import FTPHost
from ftputil.version import __version__


# Apart from `ftputil.error` and `ftputil.stat`, this is the whole
# public API of `ftputil`.
__all__ = ["FTPHost", "__version__"]