def findDottedModuleAndParentDir(file_path):
if not os.path.isfile(file_path):<EOL><INDENT>raise ValueError("<STR_LIT>".format(file_path))<EOL><DEDENT>parent_dir = os.path.dirname(os.path.abspath(file_path))<EOL>dotted_module = os.path.basename(file_path).replace('<STR_LIT>', '<STR_LIT>')<EOL>while isPackage(parent_dir):<EOL><INDENT>dotted_module = os.path.basename(parent_dir) + '<STR_LIT:.>' + dotted_module<EOL>parent_dir = os.path.dirname(parent_dir)<EOL><DEDENT>debug("<STR_LIT>".format(<EOL>parent_dir, dotted_module), <NUM_LIT:2>)<EOL>return (dotted_module, parent_dir)<EOL>
I return a tuple (dotted_module, parent_dir) where dotted_module is the
full dotted name of the module with respect to the package it is in, and
parent_dir is the absolute path to the parent directory of the package.

If the python file is not part of a package, I return (None, None).

For for filepath /a/b/c/d.py where b is the package, ('b.c.d', '/a')
would be returned.