CMS 3D CMS Logo

Public Member Functions | Public Attributes

TreeCrawler::Package Class Reference

List of all members.

Public Member Functions

def __init__
def dump
def search

Public Attributes

 dependencies
 hit
 module
 name
 searched
 stack

Detailed Description

Definition at line 50 of file TreeCrawler.py.


Constructor & Destructor Documentation

def TreeCrawler::Package::__init__ (   self,
  name,
  top = False 
)

Definition at line 51 of file TreeCrawler.py.

00052                                      :
00053         self.name = name
00054         self.dependencies = []
00055         self.searched = False
00056         self.stack = []
00057         if top:
00058             self.module = None
00059         else:    
            self.module = __import__(name,[],[],"*")

Member Function Documentation

def TreeCrawler::Package::dump (   self,
  level 
)

Definition at line 60 of file TreeCrawler.py.

00061                         :
00062         indent = "  " * level
00063         print indent, "+", Color.info, self.name, Color.none
00064         # sort dependencies alphabetically
00065         self.dependencies.sort(key = lambda x: x.name)
00066         for package in self.dependencies:
            package.dump(level+1)
def TreeCrawler::Package::search (   self,
  pattern,
  result 
)
recursive search for pattern in source files

Definition at line 67 of file TreeCrawler.py.

00068                                    :
00069         """ recursive search for pattern in source files"""
00070         # first start searching in the package itself / do this only once
00071         if self.module:
00072             for number, line in enumerate(inspect.getsource(self.module).splitlines()):
00073                 if pattern in line:
00074                      filename = packageNameFromFilename(inspect.getsourcefile(self.module))
00075                      if not self.searched:
00076                          # save the hit, so we can add later stacks to it
00077                          self.hit = SearchHit()
00078                          self.hit.number = number
00079                          self.hit.filename = filename
00080                          self.hit.line = line
00081                          self.hit.stacks = list()
00082                          result.append(self.hit)
00083                      self.hit.stacks.append(copy.copy(_stack)) 
00084         # then go on with dependencies
00085         _stack.append(self.name)
00086         for package in self.dependencies:
00087             package.search(pattern,result)
00088         _stack.pop() 
00089         self.searched = True    
00090 


Member Data Documentation

Definition at line 51 of file TreeCrawler.py.

Definition at line 67 of file TreeCrawler.py.

Definition at line 51 of file TreeCrawler.py.

Definition at line 51 of file TreeCrawler.py.

Definition at line 51 of file TreeCrawler.py.

Definition at line 51 of file TreeCrawler.py.