from os.path import abspath, isdir, dirname, basename, join, pardir
import pkgutil
def bfs10103(bfs10077):
  bfs10100 = pkgutil.get_loader(bfs10077)
  try:
    filename = bfs10100.filename
  except AttributeError:
    filename = bfs10100.get_filename(bfs10077)

  bfs10101 = abspath(dirname(filename))
  is_package = (basename(filename) in ('__init__.py', '__init__.pyc'))
  if is_package:
    bfs10101 = abspath(join(bfs10101, pardir))

  while (not isdir(bfs10101)):
    bfs10101 = abspath(join(bfs10101, pardir))

  return bfs10101

