TopDl: example3.py

File example3.py, 394 bytes (added by faber, 12 years ago)

Python topdl editing example

Line 
1#!/usr/bin/env python
2
3import sys
4from deter import topdl
5
6if len(sys.argv) < 2:
7    sys.exit('Usage: %s topdl_file' % sys.argv[0])
8
9top = topdl.topology_from_xml(filename=sys.argv[1], top='experiment')
10
11for i, e in enumerate(top.elements):
12    if not isinstance(e, topdl.Computer): continue
13    e.set_attribute('computer_number', '%s' % i)
14
15
16print topdl.topology_to_xml(top, top='experiment')