| 1271 | <Page #11 zzz (1000pt, 1000pt)> |
| 1272 | """ |
| 1273 | class PageNode: |
| 1274 | def __init__(self, path=None, page=None): |
| 1275 | self.path = path2Url(path) |
| 1276 | self.page = page |
| 1277 | self.children = [] |
| 1278 | def __getitem__(self, name): |
| 1279 | for child in self.children: |
| 1280 | if child.path and child.path.split('/')[-1] == name: |
| 1281 | return child |
| 1282 | return None |
| 1283 | def __len__(self): |
| 1284 | return len(self.children) |
| 1285 | def __repr__(self): |
| 1286 | l = [] |
| 1287 | for child in self.children: |
| 1288 | l.append(child.path) |
| 1289 | return '<%s path=%s page=%s %s>' % (self.__class__.__name__, self.path, self.page, l) |
| 1290 | def show(self, tab=0): |
| 1291 | print('\t'*tab, id(self), self) |
| 1292 | for child in self.children: |
| 1293 | child.show(tab+1) |
| 1294 | def getNode(self, path): # Answer the node with this path, oatherwise add it. |
| 1295 | if path is None: |
| 1296 | return None |
| 1297 | for child in self.children: |
| 1298 | if path is not None and path == child.path: |
| 1299 | return child |
| 1300 | |
| 1301 | node = PageNode(path) |
| 1302 | self.children.append(node) |
| 1303 | return node |
| 1304 | |
| 1305 | def addPageNode(page, node): |
| 1306 | if page.url: |
no outgoing calls
no test coverage detected