# -*- coding: utf-8 -*-
## CLIG v. 1.2.0
## Dieter Hilfer 30.10.2009
## Licensed under GPLv2
## http://clig.sourceforge.net/
"""
walk recursive tru subdirs, serach for py files, add dirs to sys.path
"""
import os, sys
allready_run=False
def updatePythonPath(dirpath):
## start=time.clock()
global allready_run
if allready_run:
return
allready_run=True
## print "Expand Python path in ",os.path.realpath(dirpath)
directories={}
#search for relevant directories
for root, dirs, files in os.walk(dirpath):
for name in files:
filename,extension=os.path.splitext(name)
dir_path=unicode(os.path.realpath(os.path.normpath(root)))
if (extension==".py" or extension==".pyc"):
# this dir has a py file -> take it
if directories.get(dir_path) is None:
# dir is not known yet
directories[dir_path]=0
break
for dir in directories.keys():
sys.path.append(dir)
## print "Run done in ", str(time.clock()-start), "s"