pypi /


import sys

class Node:
    def __init__(self, id=None, name=None, path=None, path_split=None):
        self.arcs = {} = id = name
        self.path = path
        self.path_split = path_split
        if path_split:
            self.level = len(path_split)
            self.level = 1

    def __repr__(self):
        return '<Node %d %s>'%(,

    def subtree_ids(self):
        result = []
        for node in self.arcs.values():
        return result

class Trove:
    def __init__(self, cursor):
        self.root = Node()
        self.trove = {}
        cursor.execute('select id,classifier from trove_classifiers order by classifier')

        # now generate the tree
        for id, line in cursor.fetchall():
            id = int(id)
            d = self.root
            # make this a tuple so we can use it as a key
            path_split = tuple([s.strip() for s in line.split('::')])
            for arc in path_split:
                if d.arcs.has_key(arc):
                    d = d.arcs[arc]
                    n = Node(id, arc, line.strip(), path_split)
                    self.trove[id] = n
                    d.arcs[arc] = n
                    d = n
        self.FIELDS = self.root.arcs.keys()

    def getid(self, path):
        node = self.root
        for arc in path:
            node = node.arcs[arc]

    def __getitem__(self, key):
        return self.trove[key]

        'Development Status':1,
        'Natural Language':1,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.