mirror of
https://github.com/Deepshift/DeepCreamPy.git
synced 2024-12-01 04:00:21 +00:00
Add files via upload
I made file.py to make decensor.py more clear. For release version, must change False to True, to print what files are not going to be decensored file.check_file( input_dir, output_dir, False) --> file.check_file( input_dir, output_dir, True) (it's about solving #25)
This commit is contained in:
parent
f17061a876
commit
f6812b9d6a
55
file.py
Normal file
55
file.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
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:
|
||||||
|
lhs.lowwer()
|
||||||
|
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")
|
||||||
|
|
||||||
|
error_messages(files_removed)
|
||||||
|
input("\nPress anything to continue...")
|
||||||
|
|
||||||
|
print("\n###################################\n")
|
||||||
|
|
||||||
|
return file_list, files_removed
|
||||||
|
|
||||||
|
def error_messages(file_lists):
|
||||||
|
|
||||||
|
if len(file_lists) ==0:
|
||||||
|
return
|
||||||
|
|
||||||
|
for remove_this,reason in file_lists:
|
||||||
|
file_list.remove(remove_this)
|
||||||
|
if reason == 0:
|
||||||
|
print(" REMOVED : (" + str(remove_this) +") is not PNG file format")
|
||||||
|
elif reason == 1:
|
||||||
|
print(" REMOVED : (" + str(remove_this) +") already exists")
|
||||||
|
elif reason == 2:
|
||||||
|
print(" REMOVED : (" + str(remove_this) +") file unreadable")
|
Loading…
Reference in New Issue
Block a user