def add_path(path, config=None):
<EOL>log.debug('<STR_LIT>' % path)    <EOL>if not path:<EOL><INDENT>return []<EOL><DEDENT>added = []<EOL>parent = os.path.dirname(path)<EOL>if (parent<EOL>and os.path.exists(os.path.join(path, '<STR_LIT>'))):<EOL><INDENT>added.extend(add_path(parent, config))<EOL><DEDENT>elif not path in sys.path:<EOL><INDENT>log.debug("<STR_LIT>", path)<EOL>sys.path.insert(<NUM_LIT:0>, path)<EOL>added.append(path)<EOL><DEDENT>if config and config.srcDirs:<EOL><INDENT>for dirname in config.srcDirs:<EOL><INDENT>dirpath = os.path.join(path, dirname)<EOL>if os.path.isdir(dirpath):<EOL><INDENT>sys.path.insert(<NUM_LIT:0>, dirpath)<EOL>added.append(dirpath)<EOL><DEDENT><DEDENT><DEDENT>return added<EOL>
Ensure that the path, or the root of the current package (if
    path is in a package), is in sys.path.