mirror of https://github.com/flaggo/pydu.git
add doc for request
This commit is contained in:
parent
f79009ce16
commit
74dd3ffe1b
|
@ -26,5 +26,6 @@ Content
|
|||
console
|
||||
dict
|
||||
misc
|
||||
request
|
||||
set
|
||||
string
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
Request
|
||||
-------
|
||||
|
||||
.. py:class:: pydu.request.Filename
|
||||
|
||||
Supply several methods to get filename.
|
||||
|
||||
.. py:staticmethod:: from_url(url):
|
||||
|
||||
Detected filename as unicode or None.
|
||||
|
||||
.. py:staticmethod:: from_headers(headers):
|
||||
|
||||
Detect filename from Content-Disposition headers if present.
|
||||
``headers`` could be a dict, list or string.
|
||||
|
||||
|
||||
.. py:function:: pydu.request.download(url, dst=None)
|
||||
|
||||
High level function, which downloads URL into tmp file in current
|
||||
directory and then renames it to filename autodetected from either URL
|
||||
or HTTP headers.
|
||||
``url`` indicates which url to download.
|
||||
``dst`` is the filename or directory of destination. ``None`` as default, means
|
||||
download to current directory.
|
|
@ -30,7 +30,6 @@ class FileName(object):
|
|||
Detect filename from Content-Disposition headers if present.
|
||||
|
||||
headers: as dict, list or string
|
||||
filename: from content-disposition header or None
|
||||
"""
|
||||
if not headers:
|
||||
return None
|
||||
|
@ -73,9 +72,8 @@ def download(url, dst=None):
|
|||
directory and then renames it to filename autodetected from either URL
|
||||
or HTTP headers.
|
||||
|
||||
bar: function to track download progress (visualize etc.)
|
||||
out: output filename or directory
|
||||
filename: where URL is downloaded to
|
||||
url: which url to download
|
||||
dst: filename or directory of destination
|
||||
"""
|
||||
# detect of dst is a directory
|
||||
dst_ = None
|
||||
|
|
Loading…
Reference in New Issue