This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcreate.py
58 lines (44 loc) · 1.83 KB
/
create.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import json
import os
import shutil
###
# This script will create a folder with all icons named after their uid,
# based on a json file which contains the required information.
###
# Folder containing named icons
namedFolder = 'name'
# Output folder for icons with uid names
outputFolder = 'uid'
# Set this to the old output folder if you want to create based on it
baseFolder = 'icons'
# Set this true if you always want to use the base icon when in doubt
forceBase = False
# Data used for matching
# Must contain uid and icon
correlationSet = 'correlation.json'
with open(correlationSet, encoding='utf-8') as json_file:
items = json.load(json_file)
for item in items:
src = namedFolder + os.path.sep + item['icon']
if not os.path.exists(src):
print(item['uid'] + " - Could not find: " + src)
baseSrc = baseFolder + os.path.sep + item['uid'] + '.png'
if not os.path.exists(baseSrc):
print(item['uid'] + " - Could not find base source at: " + baseSrc)
continue
print(item['uid'] + " - Found base source at: " + baseSrc)
if not forceBase:
print(item['uid'] + " - Do you want to use this icon? [Y/n]")
if input().lower() == 'n':
continue
try:
dest = outputFolder + os.path.sep + item['uid'] + '.png'
shutil.copyfile(baseSrc, dest)
except Exception as e:
print(item['uid'] + " - Error while copying icon: " + str(e))
continue
try:
dest = outputFolder + os.path.sep + item['uid'] + '.png'
shutil.copyfile(src, dest)
except Exception as e:
print(item['uid'] + " - Error while copying icon: " + str(e))