-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_helpers.py
37 lines (27 loc) · 964 Bytes
/
run_helpers.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
'''
Created on 30. mar. 2017
@author: tsy
'''
import os
import xml.etree.ElementTree as ET
def list_factions():
ls = os.listdir(os.path.join(os.path.dirname(__file__), 'The-9th-Age'))
#remove .cat extension
newlist = []
newlist.append([L[0:-4] for L in ls])
return newlist[0]
def list_units(filename=None):
#filename without extension
assert filename is not None
cwd = os.getcwd()
os.chdir(os.path.join(os.path.dirname(__file__), 'The-9th-Age'))
tree = ET.parse(filename+'.cat')
root = tree.getroot()
namelist=[]
for child in root.iter('{http://www.battlescribe.net/schema/catalogueSchema}selectionEntry'):
if child.attrib['type']=='model':
namelist.append(child.attrib['name'])
elif child.attrib['type']=='unit':
namelist.append(child.attrib['name'])
os.chdir(cwd)
return(namelist)