Skip to content
Permalink
83460e9671
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
1 contributor

Users who have contributed to this file

28 lines (21 sloc) 632 Bytes
import ftplib
class FTPEntry:
"""
Class to determine if a ftp-path is file or directory.
"""
def __init__(self, filename, ftpobj, startingdir=None):
self.filename = filename
if startingdir is None:
startingdir = ftpobj.pwd()
try:
ftpobj.cwd(filename)
self.filetype = 'd'
ftpobj.cwd(startingdir)
except ftplib.error_perm:
self.filetype = 'f'
def gettype(self):
return self.filetype
def getfilename(self):
return self.filename
def __repr__(self):
return self.filename, self.filetype