Changeset 2e0a952 for fedd


Ignore:
Timestamp:
May 17, 2010 6:12:04 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
4a53c72
Parents:
f00fb7d
Message:

Take topdl input

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/compose.py

    rf00fb7d r2e0a952  
    255255    return (top, marks)
    256256
     257def import_topdl_component(fn):
     258    top = topdl.topology_from_xml(filename=fn, top='experiment')
     259    marks = { }
     260    for e in [ e for e in top.elements if isinstance(e, topdl.Computer)]:
     261        if e.get_attribute('composition_point'):
     262            r = e.get_attribute('required') or 'false'
     263            a = e.get_attribute('accepts')
     264            p = e.get_attribute('provides')
     265            if a and p:
     266                c = constraint(name=e.name, required=(r == 'required'),
     267                    provides=p.split(','), accepts=a.split(','))
     268                marks[e.name] = c
     269    return (top, marks)
     270
    257271def index_constraints(constraints, provides, accepts):
    258272    """
     
    319333provides = { }
    320334accepts = { }
     335imp = ( (('.tcl', '.ns'), import_ns2_component),
     336        (('.xml', '.topdl'), import_topdl_component),
     337        )
    321338for fn, cnt in files:
    322339    try:
    323         top, marks = import_ns2_component(fn)
     340        for suffix, importer in imp:
     341            if fn.endswith(suffix):
     342                top, marks = importer(fn)
     343                break
     344        else:
     345            print >>sys.stderr, "Unknown suffix on file %s.  Ignored" % fn
     346            continue
    324347    except service_error, e:
    325348        print >>sys.stderr, "Remote error on %s: %s" % (fn, e)
Note: See TracChangeset for help on using the changeset viewer.