Esempio n. 1
0
    def build_tree(self, query):
        """Perform grep search and sort results into GrepTree."""
        # Grep for expresion
        searcher = Searcher(self.config, self.FILE_PATTERNS)
        results = searcher.grep_for(query)

        # Create a temp tree and add all results to tree
        tree = GrepTree()
        self.add_to_tree(results, tree)

        return tree
Esempio n. 2
0
    def from_pipe(cls, config):
        """Create Reader and read tree from incomming pipe."""
        temp = cls(config)
        try:
            temp.tree = GrepTree.load(sys.stdin)
        except ValueError:
            if temp.debug:
                warn("Choked on input from pipe")
            temp.tree = GrepTree()

        return temp
Esempio n. 3
0
 def __init__(self, config):
     self.tree = GrepTree()
     self.config = config
     self.debug = config.debug