code: def findDottedModuleAndParentDir(file_path):
      
      if not os.path.isfile(file_path):
          raise ValueError("'{}' is not a file.".format(file_path))
      parent_dir = os.path.dirname(os.path.abspath(file_path))
      dotted_module = os.path.basename(file_path).replace('.py', '')
      while isPackage(parent_dir):
          dotted_module = os.path.basename(parent_dir) + '.' + dotted_module
          parent_dir = os.path.dirname(parent_dir)
      debug("Dotted module: {} -> {}".format(
          parent_dir, dotted_module), 2)
      return (dotted_module, parent_dir)
docs: 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.