Material: tools, add def to read and write a bunch of mat cards

This commit is contained in:
Bernd Hahnebach
2019-02-19 07:06:01 +01:00
committed by Yorik van Havre
parent e3793e6c88
commit 1b69cc58a1

View File

@@ -126,6 +126,28 @@ def getMaterialAttributeStructure(withSpaces=None):
return tree
def read_cards_from_path(cards_path):
from os import listdir
from os.path import isfile, join, basename, splitext
from importFCMat import read
only_files = [f for f in listdir(cards_path) if isfile(join(cards_path, f))]
mat_files = [f for f in only_files if basename(splitext(f)[1]) == '.FCMat' or basename(splitext(f)[1]) == '.fcmat']
# print(mat_files)
mat_cards = []
for f in sorted(mat_files):
mat_cards.append(read(join(cards_path, f)))
return mat_cards
def write_cards_to_path(cards_path, cards_data):
from importFCMat import write
from os.path import join
for card_data in cards_data:
card_path = join(cards_path, (card_data['CardName'] + '.FCMat'))
print(card_path)
write(card_path, card_data)
if __name__ == '__main__':
import sys
import getopt