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
|
console
|
||||||
dict
|
dict
|
||||||
misc
|
misc
|
||||||
|
request
|
||||||
set
|
set
|
||||||
string
|
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.
|
Detect filename from Content-Disposition headers if present.
|
||||||
|
|
||||||
headers: as dict, list or string
|
headers: as dict, list or string
|
||||||
filename: from content-disposition header or None
|
|
||||||
"""
|
"""
|
||||||
if not headers:
|
if not headers:
|
||||||
return None
|
return None
|
||||||
|
@ -73,9 +72,8 @@ def download(url, dst=None):
|
||||||
directory and then renames it to filename autodetected from either URL
|
directory and then renames it to filename autodetected from either URL
|
||||||
or HTTP headers.
|
or HTTP headers.
|
||||||
|
|
||||||
bar: function to track download progress (visualize etc.)
|
url: which url to download
|
||||||
out: output filename or directory
|
dst: filename or directory of destination
|
||||||
filename: where URL is downloaded to
|
|
||||||
"""
|
"""
|
||||||
# detect of dst is a directory
|
# detect of dst is a directory
|
||||||
dst_ = None
|
dst_ = None
|
||||||
|
|
Loading…
Reference in New Issue