Changeset 7ee16b3
- Timestamp:
- May 19, 2010 6:38:05 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 966c620
- Parents:
- 8a0c67f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/compose.py
r8a0c67f r7ee16b3 231 231 if e.name in names: 232 232 nn= make_new_name(names, "node") 233 if e.name in marks:234 marks[e.name].name = nn233 for c in marks.get(e.name, []): 234 c.name = nn 235 235 e.name = nn 236 236 else: … … 254 254 """ 255 255 got_all = True 256 node_match = { } 256 257 for c in candidates: 257 258 if not c.match: … … 265 266 if can.name != c.name and can.topology != c.topology and \ 266 267 not can.match: 267 # Now check that the candidate also accepts c 268 # Don't allow multiple matches between the same nodes 269 # (the "if" above is already pretty crowded). 270 if c.name in node_match and \ 271 can.name in node_match[c.name]: 272 continue 273 # Now check that can also accepts c 268 274 for ca in can.accepts: 269 275 if ca in c.provides: … … 291 297 match.match = c 292 298 c.match = match 299 # Note the match of the nodes 300 for a, b in ((c.name, match.name), (match.name, c.name)): 301 if a in node_match: node_match[a].append(b) 302 else: node_match[a] = [ b] 293 303 else: 294 304 got_all = False … … 378 388 const_re = re.compile("\s*#\s*COMPOSITION:\s*([^:]+:[^:]+:.*)") 379 389 380 marks = { }390 constraints = [ ] 381 391 for l in contents: 382 392 m = const_re.search(l) … … 389 399 p = p.split(",") 390 400 a = a.split(",") 391 c = constraint(name=nn, required=(r == 'required'), 392 provides=p, accepts=a) 393 marks[nn] = c 394 return marks 401 constraints.append(constraint(name=nn, required=(r == 'required'), 402 provides=p, accepts=a)) 403 return constraints 395 404 396 405 def import_ns2_component(fn): … … 416 425 def import_topdl_component(fn): 417 426 """ 418 Pull a component in from a topdl description. The topology generation is 419 straightforward and the constraints are pulled from the attributes of 420 Computer nodes in the experiment. The compisition_point attribute being 421 true marks a node as a composition point. The required, provides and 422 accepts attributes map directly into those constraint fields. The dict of 423 constraints and the topology are returned. 424 """ 425 top = topdl.topology_from_xml(filename=fn, top='experiment') 426 cons = constraints_from_xml(filename=fn, top='constraints') 427 marks= dict([(c.name, c ) for c in cons]) 428 return (top, marks) 429 430 def index_constraints(constraints, provides, accepts): 427 Pull a component in from a topdl description. 428 """ 429 return (topdl.topology_from_xml(filename=fn, top='experiment'), 430 constraints_from_xml(filename=fn, top='constraints')) 431 432 def index_constraints(constraints, provides, accepts, names): 431 433 """ 432 434 Add constraints to the provides and accepts indices based on the attributes 433 of the contstraints. 435 of the contstraints. Also index by name. 434 436 """ 435 437 for c in constraints: … … 438 440 if a not in dict: dict[a] = [c] 439 441 else: dict[a].append(c) 442 if c.name in names: names[c.name].append(c) 443 else: names[c.name]= [ c ] 440 444 441 445 def get_suffix(fn): … … 548 552 549 553 for fn, cnt in files: 550 top = None551 554 try: 552 555 s = get_suffix(fn) 553 556 if s and s in importers: 554 top, marks = importers[s](fn)557 top, cons = importers[s](fn) 555 558 else: 556 559 warn("Unknown suffix on file %s. Ignored" % fn) … … 569 572 components += 1 570 573 t = top.clone() 571 m = copy.deepcopy(marks) 574 c = copy.deepcopy(cons) 575 marks = { } 572 576 # Bind the constraints in m (the marks copy) to this topology 573 for c in m.values():574 c .topology = t575 index_constraints( m.values(), provides, accepts)576 localize_names(t, names, m )577 constraints.extend( m.values())577 for cc in c: 578 cc.topology = t 579 index_constraints(c, provides, accepts, marks) 580 localize_names(t, names, marks) 581 constraints.extend(c) 578 582 topos.append(t) 579 583
Note: See TracChangeset
for help on using the changeset viewer.