source: ftputil/__init__.py @ 1713:f146a1ea66aa

Last change on this file since 1713:f146a1ea66aa was 1713:f146a1ea66aa, checked in by Stefan Schwarzer <sschwarzer@…>, 10 months ago
Remove `__future__` imports With the switch to Python 3.x-only, the `__future__` imports are no longer needed. Update copyright years along with the `__future__` import removal.
File size: 2.1 KB
Line 
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"""
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
47import sys
48import warnings
49
50from ftputil.host    import FTPHost
51from ftputil.version import __version__
52
53
54# `sys.version_info.major` isn't available in Python 2.6.
55if sys.version_info[0] == 2:
56    warnings.warn("Python 2 suport will be removed in ftputil 4.0.0",
57                  DeprecationWarning, stacklevel=2)
58
59
60# Apart from `ftputil.error` and `ftputil.stat`, this is the whole
61# public API of `ftputil`.
62__all__ = ["FTPHost", "__version__"]
Note: See TracBrowser for help on using the repository browser.