initial commit
This commit is contained in:
commit
d4375bbe14
|
@ -0,0 +1,75 @@
|
|||
# Ace's deluxemenu glasspane script
|
||||
|
||||
import yaml
|
||||
import os
|
||||
from fnmatch import fnmatch
|
||||
|
||||
pattern = '*.yml'
|
||||
outputpattern = '*_output.yml'
|
||||
material = 'GLASS_PANE'
|
||||
displayname = '&f'
|
||||
|
||||
|
||||
def getfiles():
|
||||
try:
|
||||
for path, subdir, file in os.walk(os.getcwd()):
|
||||
for name in file:
|
||||
if fnmatch(name, pattern):
|
||||
if not fnmatch(name, outputpattern): # protection to not read the output files
|
||||
dmglass(os.path.join(path, name))
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
exit()
|
||||
|
||||
|
||||
def dmglass(filename):
|
||||
|
||||
path = filename
|
||||
slots = []
|
||||
result = []
|
||||
|
||||
try:
|
||||
with open(path) as file:
|
||||
cfile = yaml.full_load(file)
|
||||
size = cfile.get('size')
|
||||
items = cfile.get('items')
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
exit()
|
||||
|
||||
for i in items:
|
||||
for y in items[i]:
|
||||
if y == 'slot':
|
||||
slots.append(items[i][y])
|
||||
|
||||
# fix size
|
||||
if size in [8, 17, 26, 35, 45, 53]:
|
||||
size += 1
|
||||
|
||||
for i in range(size):
|
||||
if i not in slots:
|
||||
result.append(i)
|
||||
|
||||
#print(f'your gui size: {size}')
|
||||
#print(f'slots: {slots}')
|
||||
#print(f'result: {result}')
|
||||
|
||||
glasspanels = {} # object to write (contains above one)
|
||||
glasspanels['GlassPanels'] = {}
|
||||
glasspanels['GlassPanels']['material'] = material
|
||||
glasspanels['GlassPanels']['display_name'] = displayname
|
||||
glasspanels['GlassPanels']['slots'] = result
|
||||
try:
|
||||
outputpath = filename[:-3] # remove .yml from path
|
||||
with open(f'{outputpath}_output.yml', 'w') as outputfile:
|
||||
yaml.dump(glasspanels, outputfile)
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
exit()
|
||||
|
||||
print('output file created successfully')
|
||||
|
||||
|
||||
# Press the green button in the gutter to run the script.
|
||||
if __name__ == '__main__':
|
||||
getfiles()
|
Loading…
Reference in New Issue