Changeset 749
- Timestamp:
- 07/16/07 21:13:29 (1 year ago)
- Files:
-
- commando/trunk/commandolite.py (modified) (2 diffs)
- commando/trunk/tests/test_pathdiscovery.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
commando/trunk/commandolite.py
r748 r749 244 244 return out 245 245 246 247 def find_top_packages(where='.'): 246 def evaluate_packagedir(path, name=''): 247 if (isdir(path) and '.' not in name and ( 248 isfile(join(path, '__init__.py')) or 249 isfile(join(path, '__init__.pyc')) or 250 isfile(join(path, '__init__.pyo'))) 251 ): 252 return name or dirname(path) 253 return False 254 255 256 def find_top_packages(where='.', evaluate_packagelocation=evaluate_packagedir): 257 """Find all directories under `where` which contain an __init__.py""" 258 248 259 tops={} 249 260 out = [] … … 253 264 for name in os.listdir(where): 254 265 fn = join(where,name) 255 if isdir(fn): 256 if ('.' not in name and isfile(join(fn,'__init__.py'))): 257 tops.setdefault(where, {})[name]=fn 258 else: 259 stack.append(fn) 260 return tops 266 result = evaluate_packagelocation(fn, name=name) 267 if result: 268 tops.setdefault(where, []).append(result) 269 if isdir(fn) and not result: 270 stack.append(fn) 271 272 return sorted(tops.items()) 273 261 274 262 275 #----------------------------------------------------------------------------- commando/trunk/tests/test_pathdiscovery.py
r748 r749 24 24 #print commandolite.path_moduleinfo(sys.argv[1]) 25 25 #print commandolite.find_packages(sys.argv[1]) 26 print commandolite.find_top_packages( sys.argv[1])26 print commandolite.find_top_packages(commandolite.abs_normpath(sys.argv[1])) 27 27 28 28