Расширение функции Python os.walk на FTP-сервере

Как я могу сделатьos.walk пройти через дерево каталогов базы данных FTP (расположенной на удаленном сервере)? Код структурирован сейчас (комментарии предоставлены):

import fnmatch, os, ftplib

def find(pattern, startdir=os.curdir): #find function taking variables for both desired file and the starting directory
    for (thisDir, subsHere, filesHere) in os.walk(startdir): #each of the variables change as the directory tree is walked
        for name in subsHere + filesHere: #going through all of the files and subdirectories
            if fnmatch.fnmatch(name, pattern): #if the name of one of the files or subs is the same as the inputted name
                fullpath = os.path.join(thisDir, name) #fullpath equals the concatenation of the directory and the name
                yield fullpath #return fullpath but anew each time

def findlist(pattern, startdir = os.curdir, dosort=False):
    matches = list(find(pattern, startdir)) #find with arguments pattern and startdir put into a list data structure
    if dosort: matches.sort() #isn't dosort automatically False? Is this statement any different from the same thing but with a line in between
    return matches

#def ftp(
#specifying where to search.

if __name__ == '__main__':
    import sys
    namepattern, startdir = sys.argv[1], sys.argv[2]
    for name in find(namepattern, startdir): print (name)

Я думаю, что мне нужно определить новую функцию (т.е.def ftp()), чтобы добавить эту функциональность в код выше. Тем не менее, я боюсь, чтоos.walk По умолчанию функция будет обходить только деревья каталогов компьютера, с которого запускается код.

Есть ли способ, которым я могу расширить функциональностьos.walk быть в состоянии пройти через удаленное дерево каталогов (через FTP)?

Ответы на вопрос(2)

Ваш ответ на вопрос