basename ( name ) if not name : return None return name def filename_fix_existing ( filename ) : """ Expands name portion of filename with numeric ' (x) ' suffix to return filename that doesn ' t exist already. startswith ( ' filename= ' ) ] if len ( fnames ) > 1 : return None name = fnames. lower ( ) not in ( ' inline ', ' attachment ' ) : return None # several filename params is illegal, but just in case fnames = if x. split ( ' ' ) if len ( cdtype ) = 1 : return None if cdtype. get ( " Content-Disposition " ) if not cdisp : return None cdtype = cdisp. splitlines ( ) if type ( headers ) = list : headers = dict ( ) cdisp = headers. ![]() :param: headers as dict, list or string :return: filename from content-disposition header or None """ if type ( headers ) = str : headers = headers. ![]() " ) ) = 0 : return None return fname def filename_from_headers ( headers ) : """ Detect filename from Content-Disposition headers if present. parse as urlparse else : import urllib import urlparse _version_ = " 2.2 " def filename_from_url ( url ) : """ :return: detected filename or None """ fname = os. version_info > = ( 3, 0 ) if PY3K : import urllib. Public domain by anatoly techtonik Also available under the terms of MIT license Copyright (c) 2010-2014 anatoly techtonik """ import sys, shutil, os import tempfile import math PY3K = sys. ![]() #!/usr/bin/env python """ Download utility as an easy way to get file from the net python -m wget python wget.py Downloads: Development: wget.py is not option compatible with Unix wget utility, to make command line interface intuitive for new people.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |