Join value to existing attribute via space. Or create new attribute if not exists. Useful to operate with token classes.
(self, name: str, value: str)
| 104 | return self.attrs.get(name, None) |
| 105 | |
| 106 | def attrJoin(self, name: str, value: str) -> None: |
| 107 | """Join value to existing attribute via space. |
| 108 | Or create new attribute if not exists. |
| 109 | Useful to operate with token classes. |
| 110 | """ |
| 111 | if name in self.attrs: |
| 112 | current = self.attrs[name] |
| 113 | if not isinstance(current, str): |
| 114 | raise TypeError( |
| 115 | f"existing attr 'name' is not a str: {self.attrs[name]}" |
| 116 | ) |
| 117 | self.attrs[name] = f"{current} {value}" |
| 118 | else: |
| 119 | self.attrs[name] = value |
| 120 | |
| 121 | def copy(self, **changes: Any) -> Token: |
| 122 | """Return a shallow copy of the instance.""" |
no outgoing calls