2014-06-11 2 views
0

이 파일은 program이며 파일을 삭제하거나 이름을 변경하거나 수정하면 디렉토리를 검사합니다. 특정 파일을 제외 시켜서 디렉토리를 어떻게 확인할 수 있습니까? 변수 PATH_TO_WATCH = ["C:/myDirectory"]을 수정하여 프로그램이 C:/myDirectory을 검사하지만 검사에서 2 개의 파일 (file1.txt 및 file2.txt)을 제외 시키려면 어떻게합니까?디렉토리 목록에서 파일 제외하기

답변

0

다음 코드는 반드시 교체해야합니다.

for action, file in results: 
    if (file != 'file1.txt' and file != 'file2.txt'): #here you cut the check of the files you don't want. 
    full_filename = os.path.join (path_to_watch, file) 
    if not os.path.exists (full_filename): 
     file_type = "<deleted>" 
    elif os.path.isdir (full_filename): 
     file_type = 'folder' 
    else: 
     file_type = 'file' 
    yield (file_type, full_filename, ACTIONS.get (action, "Unknown")) 
:이 코드에 의해

for action, file in results: 
    full_filename = os.path.join (path_to_watch, file) 
    if not os.path.exists (full_filename): 
    file_type = "<deleted>" 
    elif os.path.isdir (full_filename): 
    file_type = 'folder' 
    else: 
    file_type = 'file' 
    yield (file_type, full_filename, ACTIONS.get (action, "Unknown")) 

관련 문제