add 'unexpected directories' warning

This commit is contained in:
rolux 2012-09-23 11:58:43 +02:00
parent 6fe330b0c4
commit f324f8bc38

View file

@ -79,6 +79,7 @@ def organize():
'non-canonical filenames': [], 'non-canonical filenames': [],
'non-canonical filenames (target exists)': [], 'non-canonical filenames (target exists)': [],
'system files': [], 'system files': [],
'unexpected directories': [],
'unexpected files': [], 'unexpected files': [],
'unknown extensions': [] 'unknown extensions': []
} }
@ -99,8 +100,9 @@ def organize():
if is_system_file(filename): if is_system_file(filename):
issues['system files'].append(path) issues['system files'].append(path)
else: else:
# unexpected files # unexpected files, unexpected directories
length = len(path.split('/')) parts = path.split('/')
length = len(parts)
if length < 4: if length < 4:
issues['unexpected files'].append(path) issues['unexpected files'].append(path)
if length <= 4: if length <= 4:
@ -114,6 +116,8 @@ def organize():
if not file['hash'] in files_by_hash: if not file['hash'] in files_by_hash:
files_by_hash[file['hash']] = [] files_by_hash[file['hash']] = []
files_by_hash[file['hash']].append(file) files_by_hash[file['hash']].append(file)
elif not parts[3] in ['Extras', 'Versions']:
issues['unexpected direcories'].append(path)
if not dirnames and (not filenames or not filter(lambda x: not is_system_file(x), filenames)): if not dirnames and (not filenames or not filter(lambda x: not is_system_file(x), filenames)):
issues['empty directories'].append(relative_path) issues['empty directories'].append(relative_path)
@ -212,8 +216,10 @@ def organize():
keys = { keys = {
'automatic': { 'automatic': {
'remove': [ 'remove': [
'empty directories', 'system files', 'empty directories',
'unexpected files', 'unknown extensions' 'system files',
'unexpected files',
'unknown extensions'
], ],
'rename': [ 'rename': [
'incorrect filenames', 'incorrect filenames',
@ -226,8 +232,11 @@ def organize():
'non-canonical filenames (target exists)' 'non-canonical filenames (target exists)'
], ],
'resolve': [ 'resolve': [
'duplicate files', 'missing subtitles', 'duplicate files',
'missing video', 'multiple versions' 'missing subtitles',
'missing video',
'multiple versions',
'unexpected directories'
] ]
} }
} }