t.append(cmd, kind) adds a new step at the end.
(self, cmd, kind)
| 111 | self.debugging = flag |
| 112 | |
| 113 | def append(self, cmd, kind): |
| 114 | """t.append(cmd, kind) adds a new step at the end.""" |
| 115 | if not isinstance(cmd, str): |
| 116 | raise TypeError('Template.append: cmd must be a string') |
| 117 | if kind not in stepkinds: |
| 118 | raise ValueError('Template.append: bad kind %r' % (kind,)) |
| 119 | if kind == SOURCE: |
| 120 | raise ValueError('Template.append: SOURCE can only be prepended') |
| 121 | if self.steps and self.steps[-1][1] == SINK: |
| 122 | raise ValueError('Template.append: already ends with SINK') |
| 123 | if kind[0] == 'f' and not re.search(r'\$IN\b', cmd): |
| 124 | raise ValueError('Template.append: missing $IN in cmd') |
| 125 | if kind[1] == 'f' and not re.search(r'\$OUT\b', cmd): |
| 126 | raise ValueError('Template.append: missing $OUT in cmd') |
| 127 | self.steps.append((cmd, kind)) |
| 128 | |
| 129 | def prepend(self, cmd, kind): |
| 130 | """t.prepend(cmd, kind) adds a new step at the front.""" |