|
Revision 151, 1.2 kB
(checked in by cneumann, 2 years ago)
|
added: script for mechanical code conversions
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
from OperationRegistry import OperationRegistry |
|---|
| 3 |
|
|---|
| 4 |
class OperationBundle: |
|---|
| 5 |
""" Bundles a bunch of operations to be applied together. |
|---|
| 6 |
""" |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
def __init__(self): |
|---|
| 12 |
self.opList = []; |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
def addOp(self, opName): |
|---|
| 16 |
op = OperationRegistry.getRegisteredOp(opName); |
|---|
| 17 |
|
|---|
| 18 |
if op == None: |
|---|
| 19 |
print "ERROR: addOp called with unknown op \"%s\"" % opName; |
|---|
| 20 |
|
|---|
| 21 |
op.addSelf(self); |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
def subOp(self, opName): |
|---|
| 25 |
op = OperationRegistry.getRegisteredOp(opName); |
|---|
| 26 |
|
|---|
| 27 |
if op == None: |
|---|
| 28 |
print "ERROR: subOp called with unknown op \"%s\"" % opName; |
|---|
| 29 |
|
|---|
| 30 |
op.subSelf(self); |
|---|
| 31 |
|
|---|
| 32 |
def applyBundle(self, driver): |
|---|
| 33 |
for op in self.opList: |
|---|
| 34 |
op.applyOp(driver); |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
def internal_addOp(self, op): |
|---|
| 41 |
if op not in self.opList: |
|---|
| 42 |
self.opList.append(op); |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
def internal_subOp(self, op): |
|---|
| 46 |
if op in self.opList: |
|---|
| 47 |
self.opList.remove(op); |
|---|