Code Monkey home page Code Monkey logo

Comments (4)

caesar0301 avatar caesar0301 commented on May 22, 2024

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.

Cryin avatar Cryin commented on May 22, 2024

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.

c0fec0de avatar c0fec0de commented on May 22, 2024

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.

liamlundy avatar liamlundy commented on May 22, 2024

Closing due to inactivity - also seems mostly solved?

from treelib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.