1 | # Copyright (C) 2002-2018, Stefan Schwarzer <sschwarzer@sschwarzer.net> |
---|
2 | # and ftputil contributors (see `doc/contributors.txt`) |
---|
3 | # See the file LICENSE for licensing terms. |
---|
4 | |
---|
5 | """ |
---|
6 | ftputil - high-level FTP client library |
---|
7 | |
---|
8 | FTPHost objects |
---|
9 | This class resembles the `os` module's interface to ordinary file |
---|
10 | systems. In addition, it provides a method `file` which will |
---|
11 | return file-objects corresponding to remote files. |
---|
12 | |
---|
13 | # Example session |
---|
14 | with ftputil.FTPHost("ftp.domain.com", "me", "secret") as host: |
---|
15 | print(host.getcwd()) # e. g. "/home/me" |
---|
16 | host.mkdir("newdir") |
---|
17 | host.chdir("newdir") |
---|
18 | with host.open("sourcefile", "r") as source: |
---|
19 | with host.open("targetfile", "w") as target: |
---|
20 | host.copyfileobj(source, target) |
---|
21 | host.remove("targetfile") |
---|
22 | host.chdir(host.pardir) |
---|
23 | host.rmdir("newdir") |
---|
24 | |
---|
25 | There are also shortcuts for uploads and downloads: |
---|
26 | |
---|
27 | host.upload(local_file, remote_file) |
---|
28 | host.download(remote_file, local_file) |
---|
29 | |
---|
30 | Both accept an additional mode parameter. If it is "b", the |
---|
31 | transfer mode will be for binary files. |
---|
32 | |
---|
33 | For even more functionality refer to the documentation in |
---|
34 | `ftputil.txt` or `ftputil.html`. |
---|
35 | |
---|
36 | FTPFile objects |
---|
37 | `FTPFile` objects are constructed via the `file` method (`open` |
---|
38 | is an alias) of `FTPHost` objects. `FTPFile` objects support the |
---|
39 | usual file operations for non-seekable files (`read`, `readline`, |
---|
40 | `readlines`, `write`, `writelines`, `close`). |
---|
41 | |
---|
42 | Note: ftputil currently is not threadsafe. More specifically, you can |
---|
43 | use different `FTPHost` objects in different threads but not |
---|
44 | a single `FTPHost` object in different threads. |
---|
45 | """ |
---|
46 | |
---|
47 | from ftputil.host import FTPHost |
---|
48 | from ftputil.version import __version__ |
---|
49 | |
---|
50 | |
---|
51 | # Apart from `ftputil.error` and `ftputil.stat`, this is the whole |
---|
52 | # public API of `ftputil`. |
---|
53 | __all__ = ["FTPHost", "__version__"] |
---|