mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Docs: mark up FTP.connect() and FTP.login() with param lists (#114395)
Use rst substitutions to reduce raw text duplication. Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
5277d4c7db
commit
01105c7c4f
1 changed files with 70 additions and 33 deletions
|
@ -55,38 +55,56 @@ Reference
|
||||||
FTP objects
|
FTP objects
|
||||||
^^^^^^^^^^^
|
^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. Use substitutions for some param docs so we don't need to repeat them
|
||||||
|
in multiple places.
|
||||||
|
|
||||||
|
.. |param_doc_user| replace::
|
||||||
|
The username to log in with (default: ``'anonymous'``).
|
||||||
|
|
||||||
|
.. |param_doc_passwd| replace::
|
||||||
|
The password to use when logging in.
|
||||||
|
If not given, and if *passwd* is the empty string or ``"-"``,
|
||||||
|
a password will be automatically generated.
|
||||||
|
|
||||||
|
.. Ideally, we'd like to use the :rfc: directive, but Sphinx will not allow it.
|
||||||
|
|
||||||
|
.. |param_doc_acct| replace::
|
||||||
|
Account information to be used for the ``ACCT`` FTP command.
|
||||||
|
Few systems implement this.
|
||||||
|
See `RFC-959 <https://datatracker.ietf.org/doc/html/rfc959.html>`__
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
.. |param_doc_source_address| replace::
|
||||||
|
A 2-tuple ``(host, port)`` for the socket to bind to as its
|
||||||
|
source address before connecting.
|
||||||
|
|
||||||
.. class:: FTP(host='', user='', passwd='', acct='', timeout=None, \
|
.. class:: FTP(host='', user='', passwd='', acct='', timeout=None, \
|
||||||
source_address=None, *, encoding='utf-8')
|
source_address=None, *, encoding='utf-8')
|
||||||
|
|
||||||
Return a new instance of the :class:`FTP` class.
|
Return a new instance of the :class:`FTP` class.
|
||||||
When *host* is given, the method call :meth:`connect(host) <connect>`
|
|
||||||
is made by the constructor.
|
|
||||||
When *user* is given, additionally the method call
|
|
||||||
:meth:`login(user, passwd, acct) <connect>` is made.
|
|
||||||
|
|
||||||
:param str host:
|
:param str host:
|
||||||
The hostname to connect to.
|
The hostname to connect to.
|
||||||
|
If given, :code:`connect(host)` is implicitly called by the constructor.
|
||||||
|
|
||||||
:param str user:
|
:param str user:
|
||||||
The username to log in with.
|
|param_doc_user|
|
||||||
If empty string, ``"anonymous"`` is used.
|
If given, :code:`login(host, passwd, acct)` is implicitly called
|
||||||
|
by the constructor.
|
||||||
|
|
||||||
:param str passwd:
|
:param str passwd:
|
||||||
The password to use when logging in.
|
|param_doc_passwd|
|
||||||
If not given, and if *passwd* is the empty string or ``"-"``,
|
|
||||||
a password will be automatically generated.
|
|
||||||
|
|
||||||
:param str acct:
|
:param str acct:
|
||||||
Account information; see the ACCT FTP command.
|
|param_doc_acct|
|
||||||
|
|
||||||
:param timeout:
|
:param timeout:
|
||||||
A timeout in seconds for blocking operations like :meth:`connect`.
|
A timeout in seconds for blocking operations like :meth:`connect`
|
||||||
If not specified, the global default timeout setting will be used.
|
(default: the global default timeout setting).
|
||||||
:type timeout: int | None
|
:type timeout: int | None
|
||||||
|
|
||||||
:param source_address:
|
:param source_address:
|
||||||
*source_address* is a 2-tuple ``(host, port)`` for the socket
|
|param_doc_source_address|
|
||||||
to bind to as its source address before connecting.
|
|
||||||
:type source_address: tuple | None
|
:type source_address: tuple | None
|
||||||
|
|
||||||
:param str encoding:
|
:param str encoding:
|
||||||
|
@ -140,17 +158,29 @@ FTP objects
|
||||||
|
|
||||||
.. method:: FTP.connect(host='', port=0, timeout=None, source_address=None)
|
.. method:: FTP.connect(host='', port=0, timeout=None, source_address=None)
|
||||||
|
|
||||||
Connect to the given host and port. The default port number is ``21``, as
|
Connect to the given host and port.
|
||||||
specified by the FTP protocol specification. It is rarely needed to specify a
|
This function should be called only once for each instance;
|
||||||
different port number. This function should be called only once for each
|
it should not be called if a *host* argument was given
|
||||||
instance; it should not be called at all if a host was given when the instance
|
when the :class:`FTP` instance was created.
|
||||||
was created. All other methods can only be used after a connection has been
|
All other :class:`!FTP` methods can only be called
|
||||||
made.
|
after a connection has successfully been made.
|
||||||
The optional *timeout* parameter specifies a timeout in seconds for the
|
|
||||||
connection attempt. If no *timeout* is passed, the global default timeout
|
:param str host:
|
||||||
setting will be used.
|
The host to connect to.
|
||||||
*source_address* is a 2-tuple ``(host, port)`` for the socket to bind to as
|
|
||||||
its source address before connecting.
|
:param int port:
|
||||||
|
The TCP port to connect to (default: ``21``,
|
||||||
|
as specified by the FTP protocol specification).
|
||||||
|
It is rarely needed to specify a different port number.
|
||||||
|
|
||||||
|
:param timeout:
|
||||||
|
A timeout in seconds for the connection attempt
|
||||||
|
(default: the global default timeout setting).
|
||||||
|
:type timeout: int | None
|
||||||
|
|
||||||
|
:param source_address:
|
||||||
|
|param_doc_source_address|
|
||||||
|
:type source_address: tuple | None
|
||||||
|
|
||||||
.. audit-event:: ftplib.connect self,host,port ftplib.FTP.connect
|
.. audit-event:: ftplib.connect self,host,port ftplib.FTP.connect
|
||||||
|
|
||||||
|
@ -167,14 +197,21 @@ FTP objects
|
||||||
|
|
||||||
.. method:: FTP.login(user='anonymous', passwd='', acct='')
|
.. method:: FTP.login(user='anonymous', passwd='', acct='')
|
||||||
|
|
||||||
Log in as the given *user*. The *passwd* and *acct* parameters are optional and
|
Log on to the connected FTP server.
|
||||||
default to the empty string. If no *user* is specified, it defaults to
|
This function should be called only once for each instance,
|
||||||
``'anonymous'``. If *user* is ``'anonymous'``, the default *passwd* is
|
after a connection has been established;
|
||||||
``'anonymous@'``. This function should be called only once for each instance,
|
it should not be called if the *host* and *user* arguments were given
|
||||||
after a connection has been established; it should not be called at all if a
|
when the :class:`FTP` instance was created.
|
||||||
host and user were given when the instance was created. Most FTP commands are
|
Most FTP commands are only allowed after the client has logged in.
|
||||||
only allowed after the client has logged in. The *acct* parameter supplies
|
|
||||||
"accounting information"; few systems implement this.
|
:param str user:
|
||||||
|
|param_doc_user|
|
||||||
|
|
||||||
|
:param str passwd:
|
||||||
|
|param_doc_passwd|
|
||||||
|
|
||||||
|
:param str acct:
|
||||||
|
|param_doc_acct|
|
||||||
|
|
||||||
|
|
||||||
.. method:: FTP.abort()
|
.. method:: FTP.abort()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue