2013-08-19 5 views
0

copy_ree의 ignore_patterns로 확장 목록을 사용하려고 시도 할 때 TypeError : unhashable 유형 : '목록'을 던지는 python 스크립트를 작성하고 있습니다. 나는 확신 할 수 없다. 1. 왜 이것이 효과가 없으며, 2. 그것을 고치는 방법.copytree의 ignore_patterns에 패턴 목록을 보내면 TypeError가 제공됩니다. unhashable type : 'list'

# allFileTypes is the list of all extensions in source_dir 
# grabbed with function getFileExtList 
allFileTypes = getFileExtList(source_dir) 
# delete the blank file type 
del allFileTypes[0] 

# Open a window to choose the files to copy 
copyList = eg.multchoicebox(msg='Select the file types to copy', 
       choices=(allFileTypes)) 

# List comprehension to make an ignore list for copytree 
ignoreList = [x for x in allFileTypes if x not in copyList] 


# Open a window to choose the destination directory 
root_dir = eg.diropenbox(title='Choose Destination Directory') 

# Take the basename of source_dir adding it to root_dir or os.mkdir will 
# will break on the existing directory 
dest_dir = os.path.join(root_dir, os.path.basename(source_dir)) 

# copytree everything from the source_dir to the dest_dir ignoring 
# all files types not chosen from the list 
copytree(source_dir, dest_dir, ignore=ignore_patterns(ignoreList)) 

답변

0
copytree(source_dir, dest_dir, ignore=ignore_patterns(*ignoreList)) 

ignore_patterns하지리스트로서, 위치 인수로서 모든 패턴을 수신한다.

관련 문제