Comments (4)
Thanks Cryin! You can solve the first problem by leaving the identifier
parameter empty when creating a node. By default, a UUID (theoretically low probability to conflict) will be assigned when identifier
is not present.
For the second, it is still absent in the library. Please feel free to add and give me a PR. Cheers!
from treelib.
Yes, you are right,i solve the first problem by store the full url path assignment identifier;
The second problem,In order to maintain the integrity of the treellib and can be maintained and upgraded.I write this function in my own code.So I put it up here:
def search_url_list(self,host,layers,filetype=''):
self.link_list=[]
for node in self.link_tree.children(self.root_node):
if node.identifier == host:
nodetmp=node
self.foreach_same_layers(nodetmp,layers)
#print x.identifier
#print x.identifier
return self.link_list
def foreach_same_layers(self, node, layers):
if layers == 1:
if node.data.url.strip():
#print 'ret: '+node.identifier
self.link_list.append(node)
return node
ret=''
#self.link_list=[]
for subnode in self.link_tree.children(node.identifier):
ret = self.foreach_same_layers(subnode, layers-1)
return ret
use by search_url_list('subhost.host.com',3,None),
This will be able to get all of the depth of 3 node,i am sorry the code May not be easy to read ,just for reference.
from treelib.
I also looked into that topic some months ago. At the end of the day, the problem is the Tree object. But changing this would break everything.
This might be of interest for you http://anytree.readthedocs.io/en/latest/
from treelib.
Closing due to inactivity - also seems mostly solved?
from treelib.
Related Issues (20)
- Create nodes with children instead of the parent HOT 2
- Create Tree object from Json HOT 3
- Cannot understand how to use 'successors' HOT 1
- Any method to add weight to edges? HOT 1
- how to replace a node with a new tree HOT 2
- how to insert a node in a tree? HOT 2
- Possible memory leak due to deepcopy ?
- Modifying a node's identifier with the . and = operator breaks the tree
- Update python version support! HOT 2
- Get truncated tree at a given depth
- Finding the nodes between two nodes HOT 1
- Problem exporting to JSON and dict
- potential bug for data parameter in Node
- Give treelib a performance improvement and persistence using leveldb/rocksdb HOT 1
- Treelib not working any longer on Google colab or https://jupyter.org/ HOT 3
- Render tree expanding only ancestors of given node
- tree.show prints binary literal to stdout HOT 3
- [Win] pip install treelib not working | Unable to download treelib library
- get error when do Huffman Coding
- change the keys in _nodes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from treelib.