forked from sriharikapu/kudosbadges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_kudos.py
37 lines (27 loc) · 911 Bytes
/
update_kudos.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
import os
import re
import oyaml as yaml
fnames = [x for x in os.listdir('images') if x.endswith('.svg')]
# Find list of kudos names, derived from the image file name.
names = []
for fname in fnames:
name = ''.join([x.lower() for x in re.sub(r'\.svg$', '', fname)])
names.append((name, fname))
# print(names)
with open('kudos.yaml', 'r') as f:
existing_kudos = yaml.load(f)
existing_kudos_names = [kudos['name'] for kudos in existing_kudos]
objs = []
for name in names:
if name[0] not in existing_kudos_names:
print(name[0])
obj = dict(name=name[0],
description='lorum',
priceFinney=1,
numClonesAllowed=10,
tags=['ipsum'],
image=name[1]
)
objs.append(obj)
with open('kudos2.yaml', 'w') as f:
f.write(yaml.dump(objs, default_flow_style=False))