1   
 2   
 3   
 4   
 5   
 6  """ 
 7  deprecated! 
 8   
 9  This module defines few algorithms for filtering declarations. 
10  """ 
11   
12  import os 
13  import algorithm 
16      """deprecated! 
17   
18      defines few algorithms for filtering declarations 
19      """ 
20   
21      @staticmethod 
23          """return os.path.normcase( os.path.normpath( some_path ) )""" 
24          return os.path.normcase( os.path.normpath( some_path ) ) 
 25   
26      @staticmethod 
28           
29          return bool( filter( lambda dir: fpath.startswith( dir ), dirs ) ) 
 30   
31      @staticmethod 
33          """ 
34          returns list of declarations that belongs to specified locations. 
35   
36          This function works recursively. Pay attention: if you remove namespace, 
37          then you remove all declarations defined within the namespace. 
38   
39          @param decls: declaration or list of declarations 
40          @type decls: L{declaration<declaration_t>} or list of L{declarations<declaration_t>} 
41   
42          @param locations: list of directories and/or files names 
43          @type locations: list of strings 
44   
45          @return: list of L{declarations<declaration_t>} 
46          """ 
47           
48           
49          temp_decls = algorithm.make_flatten( decls ) 
50          locations = map( filtering.normalize_path, locations ) 
51          dirs = filter( lambda location: os.path.isdir( location ), locations ) 
52          files = filter( lambda location: os.path.isfile( location ), locations ) 
53          result = [] 
54          for decl in temp_decls: 
55              if not decl.location: 
56                  result.append( decl ) 
57                  continue 
58              fpath = filtering.normalize_path( decl.location.file_name ) 
59              if filtering.contains_parent_dir( fpath, dirs ) or fpath in files: 
60                  result.append( decl ) 
61          return result 
 62   
63      @staticmethod 
65          """ 
66          returns list of declarations that match user specified criteria. 
67   
68          This function works recursively. 
69   
70          @param decls: declaration or list of declarations 
71          @type decls: L{declaration<declaration_t>} or list of L{declarations<declaration_t>} 
72   
73          @param matcher: callable object, that takes 1 argument - declaration 
74                          and returns True if object should stay, and false otherwise 
75   
76          @return: list of L{declarations<declaration_t>} 
77          """ 
78           
79          return filter( matcher, algorithm.make_flatten( decls ) ) 
  80