MCPcopy Create free account
hub / github.com/PageBot/PageBot / PageNode

Class PageNode

Lib/pagebot/document.py:1273–1303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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:

Callers 3

getNodeMethod · 0.85
addPageNodeMethod · 0.85
getPageTreeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected