othersalso make single file upload/download code in orig loops methods#############################################################################""import ossysftplib from getpass import getpass from mimetypes import guess_typeadd_type defaults for all clients dfltsite 'home rmi netdfltrdir dfltuser 'lutzclass ftptoolsallow these to be redefined def getlocaldir(self)return (len(sys argv and sys argv[ ]or def getcleanall(self)return input('clean target dir first?')[: in [' ',' 'def getpassword(self)return getpass'password for % on % :(self remoteuserself remotesite)def configtransfer(selfsite=dfltsiterdir=dfltrdiruser=dfltuser)""get upload or download parameters from module defaultsargsinputscmdline anonymous ftpuser='anonymouspass=emailaddr ""self nonpassive false passive ftp on by default in self remotesite site transfer to/from this site self remotedir rdir and this dir (means acct rootself remoteuser user self localdir self getlocaldir(self cleanall self getcleanall(self remotepass self getpassword(def istextkind(selfremotenametrace=true)""use mimetypes to guess if filename means text or binary for ' htmlguess is ('text/html'none)text for ' jpegguess is ('image/jpeg'none)binary for ' txt gzguess is ('text/plain''gzip')binary for unknownsguess may be (nonenone)binary mimetypes can also guess name from typesee pymailgui ""add_type('text/ -python-win'pyw'not in tables mimetypeencoding guess_type(remotenamestrict=false)allow extras mimetype mimetype or '?/?type unknownmaintype mimetype split('/')[ get st part if traceprint(maintypeencoding or ''transferring directories with ftplib