Better error handling, erc721 revamp, spaces and numbers now allowed

Added new link to OpenSea metadata doc to config.py
Added colours to main.py
Created errors in DNA_Generator.py
You can now use numbers, spaces, and all symbols except "_" in the variant naming convention
pull/48/head
Torrin Leonard 2022-01-16 16:44:52 -05:00
rodzic c67e420aa3
commit 56a0879669
4 zmienionych plików z 68 dodań i 55 usunięć

Wyświetl plik

@ -150,7 +150,7 @@ def returnData():
'''
Returns the name of "i" attribute variant
'''
name = re.sub(r'[^a-zA-Z]', "", i)
name = i.split("_")[0]
return name
def getOrder_rarity(i):
@ -229,7 +229,9 @@ def returnData():
'''
Returns "combinations" the number of all possible NFT combinations.
'''
hierarchyByNum = []
for i in hierarchy:
# Ignore Collections with nothing in them
if len(hierarchy[i]) != 0:
@ -237,10 +239,18 @@ def returnData():
else:
print("The following collection has been identified as empty:")
print(i)
combinations = 1
for i in hierarchyByNum:
combinations = combinations*i
try:
numBatches = combinations/config.nftsPerBatch
except:
print(bcolors.ERROR + "ERROR:\nnftsPerBatch in config.py needs to be a positive integer." + bcolors.RESET)
if combinations == 0:
print(bcolors.ERROR + "\nERROR:" + bcolors.RESET)
print("The number of all possible combinations is equal to 0. Please review your collection hierarchy \n "
@ -251,8 +261,6 @@ def returnData():
"\nthose in Script_Ignore:")
print(hierarchy)
numBatches = combinations/config.nftsPerBatch
if numBatches < 1:
print(bcolors.ERROR + "ERROR:" + bcolors.RESET)
print("The number of NFTs Per Batch (nftsPerBatch variable in config.py) is to high.")
@ -285,11 +293,8 @@ def generateNFT_DNA():
listAllCollections, attributeCollections, attributeCollections1, hierarchy, possibleCombinations = returnData()
print("-----------------------------------------------------------------------------")
print("The number of possible DNA combinations is " + str(possibleCombinations))
print("")
print("Generating " + str(config.maxNFTs) + " combinations of DNA. Set in config.py.")
print("")
print(f"NFT Combinations: {possibleCombinations}\n")
print(f"Generating {config.maxNFTs} combinations of DNA.\n")
DataDictionary = {}
listOptionVariant = []
@ -350,7 +355,7 @@ def generateNFT_DNA():
DataDictionary["hierarchy"] = hierarchy
DataDictionary["DNAList"] = DNAList
return DataDictionary, possibleCombinations
return DataDictionary, possibleCombinations, DNAList
def send_To_Record_JSON():
'''
@ -360,31 +365,18 @@ def send_To_Record_JSON():
repeate DNA.
'''
DataDictionary, possibleCombinations = generateNFT_DNA()
DataDictionary, possibleCombinations, DNAList = generateNFT_DNA()
ledger = json.dumps(DataDictionary, indent=1, ensure_ascii=True)
with open(os.path.join(config.save_path, "NFTRecord.json"), 'w') as outfile:
outfile.write(ledger + '\n')
try:
ledger = json.dumps(DataDictionary, indent=1, ensure_ascii=True)
with open(os.path.join(config.save_path, "NFTRecord.json"), 'w') as outfile:
outfile.write(ledger + '\n')
print(bcolors.OK + f"{len(DNAList)} NFT DNA sent to NFTRecord.json in %.4f seconds.\n" % (time.time() - time_start) + bcolors.RESET)
print("")
print("All possible combinations of DNA sent to NFTRecord.json with " + str(possibleCombinations) + " NFT DNA sequences generated in %.4f seconds" % (time.time() - time_start))
print("")
print("If you want the number of NFT DNA sequences to be higher, please add more variants or attributes to your .blend file")
print("")
# Utility functions:
# ONLY FOR TESTING, DO NOT EVER USE IF NFTRecord.json IS FULL OF REAL DATA
# THIS WILL DELETE THE RECORD:
# Note - NFTRecrod.json will be created the next time you run main.py
def clearNFTRecord(AREYOUSURE):
if AREYOUSURE == True:
os.remove("NFTRecord.json")
# clearNFTRecord()
except:
print(bcolors.ERROR + "ERROR:\nNFT DNA not sent to NFTRecord.json.\n" + bcolors.RESET)
if __name__ == '__main__':
stripColorFromName()
returnData()
send_To_Record_JSON()
clearNFTRecord()

Wyświetl plik

@ -46,15 +46,8 @@ def returnCardanoMetaData(name, description, NFT_DNA, NFT_Variants):
return metaDataDictCardano
def returnSolanaMetaData(name, description, NFT_DNA, NFT_Variants):
metaDataDictSolana = {}
metaDataDictSolana["name"] = name
metaDataDictSolana["symbol"] = ""
metaDataDictSolana["description"] = description
metaDataDictSolana["seller_fee_basis_points"] = None
metaDataDictSolana["image"] = ""
metaDataDictSolana["animation_url"] = ""
metaDataDictSolana["external_url"] = ""
metaDataDictSolana = {"name": name, "symbol": "", "description": description, "seller_fee_basis_points": None,
"image": "", "animation_url": "", "external_url": ""}
attributes = []
@ -71,21 +64,34 @@ def returnSolanaMetaData(name, description, NFT_DNA, NFT_Variants):
"name": "",
"family": ""
}
metaDataDictSolana["properties"] = {"files": [{"uri": "", "type": ""}],
"category": "",
"creators": [{"address": "", "share": None}]
}
metaDataDictSolana["properties"] = {
"files": [{"uri": "", "type": ""}],
"category": "",
"creators": [{"address": "", "share": None}]
}
return metaDataDictSolana
def returnErc721MetaData(name, description, NFT_DNA, NFT_Variants):
metaDataDictErc721 = {}
metaDataDictErc721 = {
"name": name,
"description": description,
"image": "",
"attributes": None,
}
attributes = []
for i in NFT_Variants:
dictionary = {
"trait_type": i,
"value": NFT_Variants[i]
}
attributes.append(dictionary)
metaDataDictErc721["attributes"] = attributes
metaDataDictErc721["title"] = name
metaDataDictErc721["type"] = ""
metaDataDictErc721["properties"] = {"NFT_Variants": NFT_Variants,
"description": description,
"NFT_DNA": NFT_DNA
}
return metaDataDictErc721
if __name__ == '__main__':

Wyświetl plik

@ -69,7 +69,7 @@ refactorBatchOrder = False # When set to True, sorts, renames, and moves all NF
# Set the following to True to generate the format of the Meta Data template for your NFTs blockchain. (You can use multiple)
cardanoMetaData = False # Cardano - Format Source: https://cips.cardano.org/cips/cip25/
solanaMetaData = False # Solana - Format Source: https://docs.metaplex.com/nft-standard
erc721MetaData = False # Ethereum ERC721 - Format Source: https://eips.ethereum.org/EIPS/eip-721
erc721MetaData = False # Ethereum ERC721 - Format Source: https://docs.opensea.io/docs/metadata-standards
turnNumsOff = True # When set to True, turns off the extension numbers representing order and rarity from the names of
# variants in meta Data.

Wyświetl plik

@ -10,10 +10,25 @@ dir = os.path.dirname(bpy.data.filepath)
sys.path.append(dir)
sys.modules.values()
from src import config
from src.Utility_Scripts import DuplicateChecker, RenderTest, Preview, BatchRefactorer, RarityChecker
from src.Model_Generators import Model_Generator
from src.Main_Generators import Batch_Sorter, DNA_Generator, Exporter
class bcolors:
'''
The colour of console messages.
'''
OK = '\033[92m' # GREEN
WARNING = '\033[93m' # YELLOW
ERROR = '\033[91m' # RED
RESET = '\033[0m' # RESET COLOR
try:
from src import config
from src.Utility_Scripts import DuplicateChecker, RenderTest, Preview, BatchRefactorer, RarityChecker
from src.Model_Generators import Model_Generator
from src.Main_Generators import Batch_Sorter, DNA_Generator, Exporter
except:
print(bcolors.ERROR + "ERROR:\nBlender cannot find the Blend_My_NFTs folder." + bcolors.RESET + "\nChange the "
"directory of your .blend file to be inside the Blend_My_NFTs-main folder. For more details see the README file: "
"https://github.com/torrinworx/Blend_My_NFTs\n\n")
importlib.reload(config)
importlib.reload(DuplicateChecker)