kopia lustrzana https://github.com/torrinworx/Blend_My_NFTs
Adding file sorting method to Constants.py
rodzic
d093bf9745
commit
3de95e30d8
|
@ -12,7 +12,7 @@ import json
|
|||
from collections import Counter, defaultdict
|
||||
|
||||
from . import DNA_Generator, get_combinations
|
||||
from .Constants import bcolors, removeList
|
||||
from .Constants import bcolors, removeList, remove_file_by_extension
|
||||
|
||||
|
||||
# Checks:
|
||||
|
@ -130,9 +130,7 @@ def check_FailedBatches(batch_json_save_path):
|
|||
failed_dna_index = None
|
||||
|
||||
if os.path.isdir(batch_json_save_path):
|
||||
batch_folders = os.listdir(batch_json_save_path)
|
||||
|
||||
batch_folders = [x for x in batch_folders if (x not in removeList)]
|
||||
batch_folders = remove_file_by_extension(os.listdir(batch_json_save_path))
|
||||
|
||||
for i in batch_folders:
|
||||
batch = json.load(open(os.path.join(batch_json_save_path, i)))
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
# Purpose:
|
||||
# This file is for storing or updating constant values that may need to be changes depending on system requirements and
|
||||
# different usecases.
|
||||
removeList = [".gitignore", ".DS_Store", "desktop.ini"]
|
||||
import os
|
||||
|
||||
|
||||
removeList = [".gitignore", ".DS_Store", "desktop.ini", ".ini"]
|
||||
|
||||
def remove_file_by_extension(dirlist):
|
||||
"""
|
||||
Checks if a given directory list contains any of the files or file extensions listed above, if so, remove them from
|
||||
list and return a clean dir list. These files interfer with BMNFTs operations and should be removed whenever dealing
|
||||
with directories.
|
||||
"""
|
||||
|
||||
return_dirs = []
|
||||
for directory in dirlist:
|
||||
if not str(os.path.splitext(directory)[1]) in removeList:
|
||||
return_dirs.append(directory)
|
||||
|
||||
return return_dirs
|
||||
|
||||
|
||||
class bcolors:
|
||||
"""
|
||||
|
|
|
@ -11,7 +11,7 @@ import random
|
|||
from functools import partial
|
||||
from .loading_animation import Loader
|
||||
from . import Rarity, Logic, Checks
|
||||
from .Constants import bcolors, removeList
|
||||
from .Constants import bcolors, removeList, remove_file_by_extension
|
||||
|
||||
|
||||
def get_hierarchy():
|
||||
|
|
|
@ -8,16 +8,7 @@ import time
|
|||
import json
|
||||
import datetime
|
||||
from .loading_animation import Loader
|
||||
|
||||
|
||||
class bcolors:
|
||||
"""
|
||||
The colour of console messages.
|
||||
"""
|
||||
OK = '\033[92m' # GREEN
|
||||
WARNING = '\033[93m' # YELLOW
|
||||
ERROR = '\033[91m' # RED
|
||||
RESET = '\033[0m' # RESET COLOR
|
||||
from .Constants import bcolors, removeList, remove_file_by_extension
|
||||
|
||||
|
||||
# Save info
|
||||
|
|
|
@ -8,7 +8,7 @@ import json
|
|||
import shutil
|
||||
from . import Metadata
|
||||
|
||||
from .Constants import bcolors, removeList
|
||||
from .Constants import bcolors, removeList, remove_file_by_extension
|
||||
|
||||
|
||||
def getNFType(nftBatch_save_path):
|
||||
|
@ -17,9 +17,8 @@ def getNFType(nftBatch_save_path):
|
|||
models = False
|
||||
metaData = False
|
||||
|
||||
batch1 = [x for x in os.listdir(nftBatch_save_path) if (x not in removeList)][0] # Gets first Batch and ignores removeList files
|
||||
batchContent = os.listdir(os.path.join(nftBatch_save_path, batch1))
|
||||
batchContent = [x for x in batchContent if (x not in removeList)]
|
||||
batch1 = sorted(remove_file_by_extension(os.listdir(nftBatch_save_path)))[0]
|
||||
batchContent = remove_file_by_extension(os.listdir(os.path.join(nftBatch_save_path, batch1)))
|
||||
|
||||
if "Images" in batchContent:
|
||||
images = True
|
||||
|
|
Ładowanie…
Reference in New Issue