Пример #1
0
def buildTopo(topo, topos):
    "Create topology from string with format (object, arg1, arg2,...)."
    topo_split = topo.split(',')
    topo_name = topo_split[0]
    topo_params = topo_split[1:]

    # Convert int and float args; removes the need for every topology to
    # be flexible with input arg formats.
    topo_seq_params = [s for s in topo_params if '=' not in s]
    topo_seq_params = [makeNumeric(s) for s in topo_seq_params]
    topo_kw_params = {}
    for s in [p for p in topo_params if '=' in p]:
        key, val = s.split('=')
        topo_kw_params[key] = makeNumeric(val)

    if topo_name not in topos.keys():
        raise Exception('Invalid topo_name %s' % topo_name)
    return topos[topo_name](*topo_seq_params, **topo_kw_params)
Пример #2
0
def buildTopo( topo, topos ):
    "Create topology from string with format (object, arg1, arg2,...)."
    topo_split = topo.split( ',' )
    topo_name = topo_split[ 0 ]
    topo_params = topo_split[ 1: ]

    # Convert int and float args; removes the need for every topology to
    # be flexible with input arg formats.
    topo_seq_params = [ s for s in topo_params if '=' not in s ]
    topo_seq_params = [ makeNumeric( s ) for s in topo_seq_params ]
    topo_kw_params = {}
    for s in [ p for p in topo_params if '=' in p ]:
        key, val = s.split( '=' )
        topo_kw_params[ key ] = makeNumeric( val )

    if topo_name not in topos.keys():
        raise Exception( 'Invalid topo_name %s' % topo_name )
    return topos[ topo_name ]( *topo_seq_params, **topo_kw_params )
Пример #3
0
def buildTopo(topo):
    topo_name, topo_param = topo.split(',')
    return TOPOS[topo_name](makeNumeric(topo_param))
Пример #4
0
def buildTopo(topo):
    topo_name, topo_param = topo.split( ',' )
    return TOPOS[topo_name](makeNumeric(topo_param))