source: ftputil/__init__.py @ 1689:19c512e280ca

Last change on this file since 1689:19c512e280ca was 1689:19c512e280ca, checked in by Stefan Schwarzer <sschwarzer@…>, 2 years ago
Change "dropped" to "removed" Use a more explicit word for this important change in ftputil 4.x.x. Especially non-native speakers won't miss "removed" as easily "dropped".
File size: 2.2 KB
Line 
1# Copyright (C) 2002-2013, Stefan Schwarzer <sschwarzer@sschwarzer.net>
2# and ftputil contributors (see `doc/contributors.txt`)
3# See the file LICENSE for licensing terms.
4
5"""
6ftputil - high-level FTP client library
7
8FTPHost 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
36FTPFile 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
42Note: 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
47from __future__ import absolute_import
48from __future__ import unicode_literals
49
50import sys
51import warnings
52
53from ftputil.host    import FTPHost
54from ftputil.version import __version__
55
56
57# `sys.version_info.major` isn't available in Python 2.6.
58if sys.version_info[0] == 2:
59    warnings.warn("Python 2 suport will be removed in ftputil 4.0.0",
60                  DeprecationWarning, stacklevel=2)
61
62
63# Apart from `ftputil.error` and `ftputil.stat`, this is the whole
64# public API of `ftputil`.
65__all__ = ["FTPHost", "__version__"]
Note: See TracBrowser for help on using the repository browser.