diff --git a/docs/index.rst b/docs/index.rst index 0c2982e..0973451 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -26,5 +26,6 @@ Content console dict misc + request set string diff --git a/docs/request.rst b/docs/request.rst new file mode 100644 index 0000000..52a0b91 --- /dev/null +++ b/docs/request.rst @@ -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. diff --git a/pydu/request.py b/pydu/request.py index 423530a..b74660a 100644 --- a/pydu/request.py +++ b/pydu/request.py @@ -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