| 1221 | |
| 1222 | |
| 1223 | class NameScope: |
| 1224 | def __init__(self, name="", parent=None): |
| 1225 | self._children = {} |
| 1226 | self._name = name |
| 1227 | self._parent = parent |
| 1228 | |
| 1229 | def child(self, prefix): |
| 1230 | if prefix not in self._children: |
| 1231 | new_child = NameScope(prefix, self) |
| 1232 | self._children[prefix] = [new_child] |
| 1233 | else: |
| 1234 | new_child = NameScope( |
| 1235 | f"{prefix}_{len(self._children[prefix])}", self |
| 1236 | ) |
| 1237 | self._children[prefix].append(new_child) |
| 1238 | return new_child |
| 1239 | |
| 1240 | def parent(self): |
| 1241 | return self._parent |
| 1242 | |
| 1243 | def name(self): |
| 1244 | return self._name |
| 1245 | |
| 1246 | |
| 1247 | _name_scope = NameScope() |
no outgoing calls
no test coverage detected