2019-04-22 14:36:22 +00:00
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
def check_file(input_dir, output_dir, Release_version = True):
|
|
|
|
|
file_list = []
|
|
|
|
|
output_file_list = []
|
|
|
|
|
files_removed = []
|
|
|
|
|
|
|
|
|
|
input_dir = os.listdir(input_dir)
|
|
|
|
|
output_dir = os.listdir(output_dir)
|
|
|
|
|
|
|
|
|
|
for file_in in input_dir:
|
|
|
|
|
if not file_in.startswith('.'):
|
|
|
|
|
file_list.append(file_in)
|
|
|
|
|
|
|
|
|
|
if(Release_version is True):
|
|
|
|
|
print("\nChecking valid files...")
|
|
|
|
|
for file_out in output_dir:
|
|
|
|
|
if file_out.lower().endswith('.png'):
|
|
|
|
|
output_file_list.append(file_out)
|
|
|
|
|
|
|
|
|
|
# solving https://github.com/deeppomf/DeepCreamPy/issues/25
|
|
|
|
|
# appending in list with reason as tuple (file name, reason)
|
|
|
|
|
for lhs in file_list:
|
2019-04-23 04:47:10 +00:00
|
|
|
|
lhs.lower()
|
2019-04-22 14:36:22 +00:00
|
|
|
|
if not lhs.lower().endswith('.png') :
|
|
|
|
|
files_removed.append((lhs, 0))
|
|
|
|
|
for rhs in output_file_list:
|
|
|
|
|
if(lhs == rhs):
|
|
|
|
|
files_removed.append((lhs, 1))
|
|
|
|
|
|
|
|
|
|
# seperated detecteing same file names and deleting file name list
|
|
|
|
|
# just in case of index_error and show list of files which will not go though
|
|
|
|
|
# decensor process
|
|
|
|
|
print("\n### These files will not be decensored for following reason ###\n")
|
|
|
|
|
|
2019-04-23 04:54:17 +00:00
|
|
|
|
error_messages(file_list, files_removed)
|
2019-04-22 14:36:22 +00:00
|
|
|
|
input("\nPress anything to continue...")
|
|
|
|
|
|
|
|
|
|
print("\n###################################\n")
|
|
|
|
|
|
|
|
|
|
return file_list, files_removed
|
|
|
|
|
|
2019-04-23 04:54:17 +00:00
|
|
|
|
def error_messages(file_list, files_removed):
|
2019-04-22 14:36:22 +00:00
|
|
|
|
|
2019-04-23 04:54:17 +00:00
|
|
|
|
if len(files_removed) ==0:
|
2019-04-22 14:36:22 +00:00
|
|
|
|
return
|
|
|
|
|
|
2019-04-23 04:54:17 +00:00
|
|
|
|
for remove_this,reason in files_removed:
|
|
|
|
|
file_list.remove(remove_this)
|
2019-04-22 14:36:22 +00:00
|
|
|
|
if reason == 0:
|
2019-04-23 04:54:17 +00:00
|
|
|
|
print(" REMOVED : (" + str(remove_this) +") is not PNG file format")
|
2019-04-22 14:36:22 +00:00
|
|
|
|
elif reason == 1:
|
2019-04-23 04:54:17 +00:00
|
|
|
|
print(" REMOVED : (" + str(remove_this) +") already exists")
|
2019-04-22 14:36:22 +00:00
|
|
|
|
elif reason == 2:
|
2019-04-23 04:54:17 +00:00
|
|
|
|
print(" REMOVED : (" + str(remove_this) +") file unreadable")
|