Compute a destination name from a source name. Args: name: the name to be "transformed". Returns: The transformed name. Raises: ValueError: if the source scope is used (that is, not an empty string) and the source name does not belong to the source scope.
(self, name)
| 350 | self.tmp_cyclic_ts = [] |
| 351 | |
| 352 | def new_name(self, name): |
| 353 | """Compute a destination name from a source name. |
| 354 | |
| 355 | Args: |
| 356 | name: the name to be "transformed". |
| 357 | Returns: |
| 358 | The transformed name. |
| 359 | Raises: |
| 360 | ValueError: if the source scope is used (that is, not an empty string) |
| 361 | and the source name does not belong to the source scope. |
| 362 | """ |
| 363 | scope = self.scope |
| 364 | if not name.startswith(scope): |
| 365 | raise ValueError("{} does not belong to source scope: {}.".format( |
| 366 | name, scope)) |
| 367 | rel_name = name[len(scope):] |
| 368 | name_ = self.scope_ + rel_name |
| 369 | return name_ |
| 370 | |
| 371 | |
| 372 | class Transformer(object): |
no test coverage detected