Changes between Version 4 and Version 5 of TopDl


Ignore:
Timestamp:
Oct 4, 2012 5:50:20 PM (12 years ago)
Author:
faber
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TopDl

    v4 v5  
    7373
    7474}}}
     75
     76That file is [attachment:two.xml attached] to this page.
    7577
    7678=== Substrates ===
     
    237239The topdl library is a set of python classes and function s that are [TopdlLibrary fully documented elsewhere].  This section gives a few examples that gives the feel for the library.  Each entity is represented by a class with attributes named and broken down as described above.  There are routines to import and export topologies in topdl as well as to translate between several formats, including ns2 and GENI Rspecs.
    238240
    239 The following python generates the example topdl above:
     241The following python prints the example topdl above:
    240242
    241243{{{
     
    278280}}}
    279281
    280 
     282There are also routines for changing existing topologies.  The following example numbers the computers in a topology by adding a "computer_number" attribute to them and prints the topology in topdl.
     283
     284{{{
     285#!/usr/bin/env python
     286
     287import sys
     288from deter import topdl
     289
     290if len(sys.argv) < 2:
     291    sys.exit('Usage: %s topdl_file' % sys.argv[0])
     292   
     293top = topdl.topology_from_xml(filename=sys.argv[1], top='experiment')
     294
     295for i, e in enumerate(top.elements):
     296    if not isinstance(e, topdl.Computer): continue
     297    e.set_attribute('computer_number', '%s' % i)
     298   
     299
     300print topdl.topology_to_xml(top, top='experiment')
     301
     302}}}
     303