/ Published in: Python
Given a directory path, return true if the directory contains at least one type of archive file, as specified in the list of archive extensions. Otherwise, return false. This version uses lower() to help comparison in situations where capitalization may be different.
Expand |
Embed | Plain Text
def containsArchive (dirPath): contents=os.listdir(dirPath) archiveExts=['.zip','.rar','.gz','.bz2','.tar','.r01','.r001'] archiveList=[item for item in contents if os.path.splitext(item)[-1].lower() in archiveExts] return not archiveList==list()
You need to login to post a comment.
